vscode-java
vscode-java copied to clipboard
Formatter File not respected
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
- Configure formatter file with contents as above
- 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))
{
}
@CsCherrYY Could you please take a look?
~~I can't reproduce the issue.~~ @dudeNumber4 could you provide your settings.json?
@dudeNumber4 could you try
"java.format.settings.url": "D:\\temp\\JavaFormat.xml",
Backslashes must be escaped on Windows
@dudeNumber4 could you try
"java.format.settings.url": "D:\\temp\\JavaFormat.xml",
Backslashes must be escaped on Windows
I was mistaken; the settings file was being consumed correctly, I removed my comment.
For future reference, setting java.format.settings.url on windows must use forward slashes and cannot contain spaces. If spaces or backslashes (yes, even escaped backslashes) are present, language support output will show Illegal character in opaque part at index N [path_to_settings_file]
For future reference, setting java.format.settings.url on windows must use forward slashes and cannot contain spaces. If spaces or backslashes (yes, even escaped backslashes) are present, language support output will show Illegal character in opaque part at index N [path_to_settings_file]
can add prefix file:///