redhat-developer / redhat-developer/vscode-java

Formatter File not respected when applying snippets

Open
#2,669 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

formatter preferences
Dominant language
TypeScript
Stars
2.3k
Forks
546
Avg merge
20h 1m
Merged PRs (30d)
11

Description

I have a format xml specified in Java > Format > Settings: Url. When I run the command "Open Java Formatter Settings" my file is opened. No settings in the file are respected, however. Consider just this setting:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="12">
    <profile kind="CodeFormatterProfile" name="BradsProfile" version="12">
        <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line"/>
    </profile>
</profiles>

In the editor after typing 'if' followed by 2 tabs, I end up with this:

if (condition:var(boolean)) {
    
}

I don't see any errors in "Language Support for Java."

Environment
  • Operating System: Windows 10
  • JDK version: 11.0.14.101
  • Visual Studio Code version: 1.71.0
  • Java extension version: 1.10.0
Steps To Reproduce
  1. Configure formatter file with contents as above
  2. Type if statement as above

Can be as simple as a single .java file

Current Result
if (condition:var(boolean)) {
    
}
Expected Result
if (condition:var(boolean)) 
{
    
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in a single .java file with the supplied formatter XML and the Java extension settings shown. Trace how the formatter file is loaded and applied when the if-statement snippet is expanded. Done means the configured next_line brace position is respected and the supplied reproduction no longer produces the current layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, vscode
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.