-
Notifications
You must be signed in to change notification settings - Fork 654
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
C# #if and #endif indentation is reset after formatting messing with folding of outer code #2008
Comments
From @alexandrudima on February 5, 2018 9:37 I believe the way Omnisharp (Roslyn) formats is the generally accepted way for formatting C# macros. The problem is that our folding regions are currently computed in a language agnostic way, based on indentation. |
The request for language aware folding is microsoft/vscode#3422. Moving to Omnisharp to decide whether the formatter needs to be changed or made configurable. |
This is working as designed. The C# formatter (the same formatter used in Visual Studio) always places preprocessor directives in the left column. Currently, I don't believe there's an option to change this behavior. cc @jinujoseph, @kuhlenh (and also @Pilchie) to see if this something we might want to add to Roslyn. |
So #region and #endregion are special case of preprocessor macros? They are not placed at the left most column, since September 2017 release. |
Correct |
@aeschli you can try this extension with |
Using C# Fix Format extension and |
@uday0408: FWIW, we've been asking for awhile to have an API from VS Code that languages can use to define custom folding (microsoft/vscode#3422). Once we have that, we'll be able to make folding work for #if / #endif correctly. Currently, I would suspect that the folding will not be accurate for nested #if / #endif when #else is interspersed. |
From @uday0408 on February 3, 2018 1:54
For C#, after formatting with Omnisharp installed, the #region and #endregion statements are indented at the same level of enclosing code. But #if and #endif are formatted to have no indentation, thus messing with folding when #if/#endif enclosing code is nested.
I don't know if this is Omnisharp or VSCode problem.
Steps to Reproduce:
Does this issue occur when all extensions are disabled?: Yes/No
Copied from original issue: microsoft/vscode#42861
The text was updated successfully, but these errors were encountered: