question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatter Settings File Ignoring disabling_tag/enabling_tag

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
CsCherrYYcommented, Nov 12, 2020

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.

2reactions
snjezacommented, Feb 21, 2020

@spottedmahn could you try the following:

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

instead of

// @formatter:on
...your code... 
// @formatter:off
Read more comments on GitHub >

github_iconTop Results From Across the Web

VS Code ignores Java formatter XML file - Stack Overflow
I suggest to use command Java: Open Java Formatter Settings to automatically generate a formatting profile for you.
Read more >
Java formatting and linting - Visual Studio Code
After setting the formatter profile, the Format Document command will use the specific profile to format your Java files. Editing formatter settings. The ......
Read more >
Ignoring Code - Prettier
Use “prettier-ignore” comments to ignore parts of files. Ignoring Files: .prettierignore. To exclude files from formatting, create a .prettierignore file in the ...
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
Setup; Settings; VSCode setup; Format files from CLI; Format staged files on ... Print width; Ignoring files; Saving without formatting ...
Read more >
Configure formatting rules | JetBrains Rider Documentation
Exclude files from reformatting · In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. · Switch to the Formatter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found