-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
VS Code's indentation settings aren't overridden #1859
Comments
I'm not sure we can change that. AFAIK there isn't an API to change that in the editor besides writing the setting, but I am not comfortable overwriting settings on behalf of a user. |
Considering this is the behaviour out of the box, it could be quite confusing to new users. The steps to reproduce can be simplified even more:
To fix this I think the Prettier extension would need to override the |
I think this could potentially be solved with a little alert bubble, asking the user if they want to set their workspace tab setting to match their prettier config, if the extension detects that there is a prettier config and that it doesn't match the setting |
up vote |
I just ran into the same problem and it took me a long time to find this issue.
So, do i understand correctly that in VS Code the What confused me was the following: Line 222 in affc1e5
My understanding of that sentence is that the precedence is in the following order:
This is very confusing. If you set only 1. and neither of 2. and 3. then the behaviour seems completely arbitrary. Files that already have a tabSize of 4 stay like that. Files with a tabsize of 2 also stay like that. And sometimes new files get formatted with either one. Maybe it would help clarifying the current behaviour? It definitely would help me understand, what I must configure to reliably have a tab size of 4 spaces, that also gets applied with certainty when I paste code with a tabsize of 2. |
Summary
This was discussed in #1515 (comment) and turned out to be a separate issue.
Steps To Reproduce:
.prettierrc
in it, with this content:{"tabWidth": 2}
index.js
Expected result
When I open the empty file,
Actual result
When I opened this directory in VS Code and opened
index.js
, I saw "Spaces: 4" in the status bar. Pressing the Tab key inserted 4 spaces. After adding some code with indentation to this file, formatting it with Prettier (it got correctly indented with 2 spaces), closing, and opening the file again, VS Code's autodetection worked (aseditor.detectIndentation
istrue
by default) and this time correctly showed "Spaces: 2" in the status bar, the Tab key started to work as expected too.Additional information
For my tests, I disabled other extensions that could affect this. In particular, EditorConfig and ESLint.
The EditorConfig extension doesn't have this problem. It changes the behavior of VS Code even in empty files.
#1327 might be related (the extension seems to fail to override VS Code's behavior in that case too).
VS Code Version:
1.54.3
Prettier Extension Version:
6.3.1
OS and version:
Windows 10 x64 20H2
The text was updated successfully, but these errors were encountered: