microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.38k stars 28.94k forks source link

Indent using spaces function does not convert tabs to spaces in mixed indentation text content #219821

Open wesinator opened 3 months ago

wesinator commented 3 months ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. Open a saved file that has mixed indentation whitespace content (tabs and spaces). ex:

    test with a tab
    test with a space

    mixed_indentation_example_file.txt

  2. Ctrl-Shift-P "Indent using spaces", default (4)

I expected this function to convert any tab characters present into the n number of spaces given in the functionality. This is useful for fixing content that has mixed use of whitespace indentation.

workaround: find and replace, regex mode, replace \t with four spaces

vscodenpa commented 3 months ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.90.2. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

RedCMD commented 3 months ago

there is a separate convert indentation to spaces command

wesinator commented 3 months ago

ok, I see that now. So does "Indent using spaces" only set the configuration of the indentation for any subsequent edits, the same as this bottom menu?

image

To me, calling it "Indent using spaces" indicates an action so I expected this to be the convert function. I realise now this probably isn't going to be changed.

RedCMD commented 3 months ago

correct

I agree the naming could be a bit better Indent with spaces Spaces for indentation Space indentation idk

wesinator commented 3 months ago

one could also imagine this function running the convert function and then setting subsequent edit indentation as it does.