Vscode-java: Formatter Settings File Ignoring disabling_tag/enabling_tag

Created on 21 Feb 2020  路  7Comments  路  Source: redhat-developer/vscode-java

When I specify a formatter settings file, the disable/enable formatting tags are ignored.

Environment
  • Operating System: Win10 v1909 WSL 1 Ubuntu 18.04
  • JDK version: openjdk version "11.0.5" 2019-10-15
  • Visual Studio Code version: 1.42.1 (user setup)
  • Java extension version: 0.55.1
Steps To Reproduce
  1. Change workspace settings to:
{
    "java.format.settings.url": "https://raw.githubusercontent.com/snjeza/vscode-test/master/fluent.xml"
}
  1. Wrap some code w/ // @formatter:off & // @formatter:on
  2. Do something in that code that is outside of the default for the format settings
  3. Auto format the code (ALT + SHIFT + F)

Sample project

Current Result

Code between // @formatter:off & // @formatter:on is formatted

Expected Result

Code between // @formatter:off & // @formatter:on shouldn't be formatted

Additional Informations

Before auto-format:
image

After auto-format:
image

Format setting file:
image

formatter

All 7 comments

@spottedmahn could you try the following:

// @formatter:off 
...your code... 
// @formatter:on

instead of

// @formatter:on
...your code... 
// @formatter:off

As a debugging step? Or a final solution?

Also, pointing it at a profile that doesn't override the values, i.e. they are missing, produces the same "bug"

enabling_tag and disabling_tag not listed:

image

image

Is there any solution for this issue? I have the same problem, being unable to exclude code blocks from formatting.

Could you find the setting org.eclipse.jdt.core.formatter.use_on_off_tags in the profile? This setting should be set to true to enable the disabling_tag and the enabling_tag.

I had a look and it was set to false. After changing the configuration and restarting the editor the tags work as expected. Thank you for your help! 馃槃

Was this page helpful?
0 / 5 - 0 ratings