editorconfig-vscode icon indicating copy to clipboard operation
editorconfig-vscode copied to clipboard

Blank EditorConfig still forces tab width to 4 and spaces to 2

Open JustinGrote opened this issue 3 years ago • 3 comments

Please fill-in this template.

  • [x] I have a question that is specific to this extension; thus, inappropriate for the main EditorConfig issue tracker.
  • [x] I tried running code --disable-extensions and the issue did NOT present itself.

Issue

If I have no editorconfig, and I have the following in my user settings.json

{
    "editor.tabSize": 2
}

then any tab-formatted file I open will reset the tab size to 4 and format using spaces {7B916E4C-E615-4993-AEAB-782E12AEABB5}

If I disable the extension and reopen the file, it behaves as expected. image

I've tried this with detect indentation on and off, no difference.

If I create a .editorconfig file with indent_size line, it now behaves as expected. So there appears to be an issue with a blank config where something gets initialized with a bad default value.

JustinGrote avatar Nov 26 '22 18:11 JustinGrote

I encountered the same issue after the VSCode November 2022 update.

Downgrading VSCode back to the October 2022 version (1.73.1) fixed the issue. Apparently, there have been some changes in the indent and tab size settings in VSCode

Related issues:

  • https://github.com/microsoft/vscode/issues/42740
  • https://github.com/microsoft/vscode/issues/10339
  • https://github.com/microsoft/vscode/issues/5394
  • https://github.com/microsoft/vscode/issues/135058

STOWouters avatar Dec 09 '22 11:12 STOWouters

I have the same problem.

vscode has been updated to separate tabSize and indentSize, but editorconfig-vscode applies the indent_size option in .editorconfig only to vscode's tabSize, and indentSize is This seems to be due to the fact that it has not been changed.

In the actual code, only the tabSize is generated here,

https://github.com/editorconfig/editorconfig-vscode/blob/b86ebd4e9062c76e7145bcefc1a17cf2e6cc1acc/src/api.ts#L160-L172

and the vscode setting is changed here.

https://github.com/editorconfig/editorconfig-vscode/blob/b86ebd4e9062c76e7145bcefc1a17cf2e6cc1acc/src/api.ts#L54

Also, I added the indentSize property in the debugger on this line and run it, and it was set as expected.

However, there is no indentSize in the TextEditorOptions type to actually change the code.

mazeneko avatar Dec 09 '22 12:12 mazeneko

See https://github.com/editorconfig/editorconfig-vscode/pull/358 for WIP fix

huyz avatar Apr 04 '24 08:04 huyz