Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code fixes force tabs for indentation #557

Closed
MeikTranel opened this issue Jun 10, 2018 · 6 comments
Closed

Code fixes force tabs for indentation #557

MeikTranel opened this issue Jun 10, 2018 · 6 comments

Comments

@MeikTranel
Copy link

MeikTranel commented Jun 10, 2018

When using a java code fixes, the extension forces tabs into a 4-Space indentation workspace

Environment
  • Operating System: Windows 10 1803 (RS5) Insider Preview
  • JDK version: 1.8.172
  • Visual Studio Code version: 0.25.0-insider
  • Java extension version: 0.26.0
Steps To Reproduce
  1. Set workspace to space indentation
  2. let the extension implement an interface
Current Result

Injects tabs

Expected Result

adheres to user->workspace-settings

@MeikTranel MeikTranel changed the title Code Macros force tabs for indentation Code fixes force tabs for indentation Jun 10, 2018
@fbricon
Copy link
Collaborator

fbricon commented Jun 11, 2018

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

@MeikTranel
Copy link
Author

@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?

@yaohaizh
Copy link
Collaborator

microsoft/vscode#52272

@yaohaizh
Copy link
Collaborator

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.

@fbricon
Copy link
Collaborator

fbricon commented Aug 29, 2018

Fixed with #617, thanks to @jdneo. Nice work!

@HanKruiger
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants