When using a java code fixes, the extension forces tabs into a 4-Space indentation workspace
Injects tabs
adheres to user->workspace-settings
Ok so that's interesting. Code snippets (like ctor) are indented with tabs, but vscode fixes the indentation on-the-fly, according to its preferences.
However CompletionItems are indented according to the project's .settings/org.eclipse.jdt.core.prefs, so implementing an interface's methods would have the server use the eclipse indentation settings, but vscode doesn't correct it when applying the changes, contrary to snippets. @aeschli is this intentional?
Anyways, @MeikTranel, one way to mitigate the problem is to add this to your project's .settings/org.eclipse.jdt.core.prefs:
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=4
@fbricon What you said is exactly what sparked my confusion with the title.
First i thought it was regular code snippets but then i found out it was actually only the fixes rioting.
Aren't code fixes a language server thing?
I logged an issue for vscode on this issue.
On the language side, @fbricon Which setting should be honor? If we honer eclipse setting, there is nothing left to do.
Fixed with #617, thanks to @jdneo. Nice work!
This issue persists when the fix is triggered in a different file from where the fix is applied.
For example when in a class Foo I try to call a non-existing method on an object of class Bar, and trigger the fix to implement the new method in Bar, the new method uses tabs for indentation, whereas my setting prescribes spaces. (With the same settings, it _does_ correctly indent with spaces for implementing interfaces in the same file, as in @MeikTranel's example.)
I hope I made myself clear, and would happily elaborate if anything was unclear.
Cheers!
Most helpful comment
Ok so that's interesting. Code snippets (like ctor) are indented with tabs, but vscode fixes the indentation on-the-fly, according to its preferences.
However CompletionItems are indented according to the project's
.settings/org.eclipse.jdt.core.prefs, so implementing an interface's methods would have the server use the eclipse indentation settings, but vscode doesn't correct it when applying the changes, contrary to snippets. @aeschli is this intentional?Anyways, @MeikTranel, one way to mitigate the problem is to add this to your project's
.settings/org.eclipse.jdt.core.prefs: