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

VS2019 doesn’t want to respect my solution’s .editorconfig’s C# tab settings when it auto formats code #47396

Closed
mikadumont opened this issue Sep 2, 2020 · 7 comments
Labels
Area-IDE Bug fabric-bot-test Testing the impact of changes to the fabric bot IDE-CodeStyle Built-in analyzers, fixes, and refactorings Need More Info The issue needs more information to proceed.
Milestone

Comments

@mikadumont
Copy link
Contributor

Direct customer ask copying here:

o It uses spaces still. Even after I configured the C# Text Editor settings to use tabs as well
o I generated the .editorconfig initially using the IntelliCode generator, then changed the indent style to tabs
o When I type the ‘}’ character and it ends up auto formatting to try and place my cursor in between the {} on a empty line. I have to Ctrl Z to get out of the auto formatting
o When I use refactoring suggestions, like converting a switch statement to a pattern matching statement, all the converted code is using spaces
o If I format document/selection, VS correctly uses tabs
o This almost feels like a passive aggressive way to try and convert me to spaces. Do not want 😊

@kornman00
Copy link

kornman00 commented Sep 4, 2020

Here is another example of VS2019 not only ignoring my .editorconfig, on top of it also formating using \n, when the entire file is \r\n (as can be seen at the bottom, from the document I have open behind this window). If I were to apply this "fix formatting"* then I'd have MIXED line endings, which I would only get a warning and fix prompt the NEXT time I opened the document

  • I'm not sure what formatting it wants to fix, the only difference here is it prefixed my return statement with spaces instead of tabs

image

@CyrusNajmabadi
Copy link
Member

Here is another example

@kornman00 can you provide us with a way to reproduce this? Thanks!

@jinujoseph jinujoseph added Area-IDE Bug IDE-CodeStyle Built-in analyzers, fixes, and refactorings Need More Info The issue needs more information to proceed. labels Sep 8, 2020
@jinujoseph jinujoseph added this to the Backlog milestone Sep 8, 2020
@sharwell
Copy link
Member

sharwell commented Sep 8, 2020

... I'd have MIXED line endings ...

@kornman00 This is a different issue. See #47382 and related.

@kornman00
Copy link

@kornman00 can you provide us with a way to reproduce this? Thanks!

@CyrusNajmabadi Thanks, I can work on trying to setup a minimal project to repro later this week.

However, I think I have narrowed down the issue. Initially, I created a solution level .editorconfig file which was "initially inferred by Visual Studio IntelliCode" (and also configured it to root=true). This generated the following, which I switched to my tab settings:

[*.cs]

#Core editorconfig formatting - indentation

indent_style = tabs
tab_width = 4

What do I mean by "solution level"? The sln itself references it ("Solution Items"), and it lives at the root level next to the .sln file. The two projects in the sln are in subfolders.

However, after adding a catch all to the top of the file to always use tabs everywhere, Code Style stopped using spaces

[*]
indent_style = tabs
tab_width = 4

So, it would seem that maybe the editorconfig settings that Code Style is pulling from is not narrowed to the file extension of the file being edited?

Hope this helps in the meantime

@kornman00
Copy link

...however, it would appear whatever formats expanding /// to an autogenerated xmldoc is NOT covered by that catch all. And there would appear to be other cases where this is not worked around by the catch all [*].
Typing public void Foo() { results in the closing } automatically being added and my cursor being placed { /*here*/ }. Then pressing enter:

		public void Foo()
        {

        }

The lines with the bracket have spaces. the declaration line retains the tabs, while the cursor is placed within the body and virtually indented with tabs.

@CyrusNajmabadi
Copy link
Member

@kornman00 if you can provide a repro snapshot somewhere (i.e. a git repo), along with repro steps, that would be helpful.

@ghost ghost added the fabric-bot-test Testing the impact of changes to the fabric bot label Aug 10, 2021
@ghost ghost closed this as completed Sep 15, 2021
@ghost
Copy link

ghost commented Sep 15, 2021

Closing this issue as we've seen no reply to the request for more information. If you are able to get the requested information, please add it to the issue and we will retriage it.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug fabric-bot-test Testing the impact of changes to the fabric bot IDE-CodeStyle Built-in analyzers, fixes, and refactorings Need More Info The issue needs more information to proceed.
Projects
None yet
Development

No branches or pull requests

5 participants