editorconfig / editorconfig-vscode

EditorConfig extension for Visual Studio Code
http://editorconfig.org/
MIT License
1.24k stars 119 forks source link

Editor indentation for XSD files is lost when window focus is lost #317

Open DanAtkinson opened 3 years ago

DanAtkinson commented 3 years ago

Please fill-in this template.

Delete the following condition if it doesn't apply to your case:

If the extension is not picking up the expected configuration for a file:

Issue

Visual Studio Code editorconfig-vscode
Version 1.58.1 0.16.4

Root .editorconfig File

# This is the main editor config.
root = true

# All files should use CRLF, tabs and UTF-8.
[*]
indent_style = tab
indent_size = 4
tab_width = 4
end_of_line = crlf
charset = utf-8
max_line_length = off
insert_final_newline = true
trim_trailing_whitespace = true

Are there any other relevant .editorconfig files in your project? No

Visual Studio Code Setting Default User Workspace
editor.insertSpaces true false ____
editor.tabSize 4 _ _
editor.trimAutoWhitespace true ____ ____
files.autoSave "off" "___" "___"
files.insertFinalNewline false _____ _____
files.trimTrailingWhitespace false _____ _____

File opened

./foo.xsd

Expected behavior

indent_style = tab

Actual behavior

indent_style = space

Additional comments or steps to reproduce

Taken from vscode #128475. I've included the extension and system info sections as well.

I have XML and XSD documents that use tab indentation but Code keeps switching it to spaces.

When I open the documents however, the indentation always sets to Spaces: 4, even though I have a global rule in my .editorconfig file which explictly uses tab indentation for all document types.

If I select Detect indentation from content the option then it correctly sets it to tabs. But if I then alt-tab to another window and go back to Code, the indentation reverts to Spaces: 4.

I've also tried manually setting the indentation to tabs, but the same thing happens.

Any guidance you can provide would be greatly appreciated.

Thanks in advance, Dan Atkinson

VS Code version: Code 1.58.0 (2d23c42a936db1c7b3b06f918cde29561cc47cd6, 2021-07-08T06:54:55.083Z) OS version: Windows_NT x64 10.0.19042 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz (12 x 2592)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|31.79GB (6.84GB free)| |Process Argv|--crash-reporter-id 13f7d351-0803-4f7f-ae21-9501daf3edbf| |Screen Reader|no| |VM|0%|
Extensions (28) Extension|Author (truncated)|Version ---|---|--- rainbow-brackets|2gu|0.0.6 vscode-nvm|abu|0.0.1 vscode-angular2-files|ale|1.6.4 ng-template|Ang|12.1.1 bracket-pair-colorizer|Coe|1.0.61 jshint|dba|0.11.0 vscode-eslint|dba|2.1.23 xml|Dot|2.5.1 EditorConfig|Edi|0.16.4 json-tools|eri|1.0.2 file-icons|fil|1.0.29 url-encode|fle|1.1.0 beautify|Hoo|1.5.0 fontawesome-autocomplete|Jan|1.1.2 tabsanity|jed|0.0.11 ng-bootstrap-snippets|ktr|1.0.0 json-to-ts|Mar|1.7.5 Angular-BeastCode|Mik|10.0.3 ecdc|mit|1.4.0 prettify-json|moh|0.0.3 theme-monokai-pro-vscode|mon|1.1.19 vscode-language-pack-en-GB|MS-|1.54.1 notepadplusplus-keybindings|ms-|1.0.7 indent-rainbow|ode|7.5.0 bootstrap4-vscode|the|6.1.0 sort-lines|Tyr|1.9.0 json|Zai|2.0.2
therealchjones commented 2 years ago

@DanAtkinson I've had similar behavior when settings are in conflict, but not when they're set the same. The EditorConfig extension "fixes" settings anytime a file to which .editorconfig applies (all files, for your global settings) gets focus. You can see when EditorConfig sets the configuration with each focus change, so let's check there first:

Open the "Output" panel, select "EditorConfig", clear output, change the file's indentation to tabs (use the status bar or the command pallette->"Indent Using..."), then switch to a different window and back. The EditorConfig output will add a line like:

./foo.xsd: {"insertSpaces":true,"tabSize":4}

if "insertSpaces" is false or if there's no "insertSpaces" within that new settings line, then it's not EditorConfig changing your indentation setting to spaces, but perhaps one of your other extensions. If "insertSpaces" is true then some .editorconfig file setting thinks you want this file to use spaces (perhaps a more specific filetype setting or a .editorconfig file in a closer directory, for instance). (Or, you know, it's broken, always a possibility.)

What happens when you check this?

DanAtkinson commented 2 years ago

Hi @therealchjones,

I uninstalled the extension last year as it wasn't worth the hassle due to another 'format on save' extension which meant that my XSDs was being saved with spaces.

I've just re-installed it again and can confirm that it appears to retain the indentation when the tab loses focus.

Below is the output from the EditorConfig window:

./File.xsd: {"insertSpaces":false,"tabSize":4}

Thanks Dan