redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.05k stars 420 forks source link

lineSplit not working #3683

Closed lenghan4real closed 1 week ago

lenghan4real commented 1 week ago

lineSplit in formatter not working

Environment
Steps To Reproduce
  1. configure org.eclipse.jdt.core.formatter.lineSplit=100 locally in a formatter.xml
  2. add "java.format.settings.url": "./formatter.xml",
Current Result

not split at all.

Expected Result

line split when 100

rgrunber commented 1 week ago

I just tried this out and it seems to be working well What does your directory structure look like ? What does your formatter.xml file look like ?

Note that the file given to java.format.settings.url (in your case, formatter.xml) must be a proper xml file. It should be at the root of your project (to match the path your giving) and look something :

formatter.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<profiles version="13">
  <profile kind="CodeFormatterProfile" name="MyProfile" version="13">
    <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
  </profile>
</profiles>

and in your project's .vscode/settings.json, you should have something like :

.vscode/settings.json

{
    "java.format.settings.url": "./formatter.xml"
}

I think even using a user-level setting should work, and it would find your formatter file at the root of the project.

lenghan4real commented 1 week ago

Seems the profile is incorrect. After correction, it works. Thanks a lot.