Open theswordsmahin opened 6 months ago
I think similar issues have been filed in the past. I explained the situation in https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/2942#issuecomment-1794029285 . Basically the language server has to choose between the JDT setting and the VS Code setting. Since the protocol implies the client is responsible for the setting, the language server let's the client's setting take priority. Current workaround is https://github.com/redhat-developer/vscode-java/issues/672#issuecomment-431623541 .
Also a similar issue filed in https://github.com/redhat-developer/vscode-java/issues/672 .
I think we could just introduce a setting to determine whether the client setting should override the formatter, where they clash.
My apologies, I did attempt to see if there was already a pre-existing issue but missed those.
I think we could just introduce a setting to determine whether the client setting should override the formatter, where they clash.
That would be awesome for sure, in the meantime can set the workspace settings to hard-code the tab size for everyone, as indicated in the referenced comment. Thanks for taking the time!
@theswordsmahin You can try to set the java.format.tabSize
property.
The settings editor shows that as an unknown configuration setting for me, tried it anyways but it didn't seem to work.
Did you mean
"[java]":{
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.tabSize": 4,
},
Or is there another place that option takes effect?
Did you mean
You are right. Sorry.
Java formatter ignores org.eclipse.jdt.core.formatter.tabulation.size and uses editor's 'tab size' when calculating how lines should be split. This makes it difficult for users to use their preferred indentation size without throwing off source control history diffs.
Environment
Steps To Reproduce
Relevant settings:
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
and<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
in my java formatter (full formatting file: java-formatter.xml.txt))tab size: 4
If I have a line that is 121 characters, the formatter will wrap appropriately. However, if someone else has their
tab size:2
, the total line length is calculated to be less than 120, and thus will unwrap the lines wich throws off the file history diffs.Current Result
Line split is calculated based on VS Code's tab size setting, instead of the formatter's
tabulation.size
Expected Result
Line split should be calculated based on the
tabulation.size
setting, to allow users to have their preferred tab size within VS Code