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

C# #if and #endif indentation is reset after formatting messing with folding of outer code #42861

Closed
uday0408 opened this issue Feb 3, 2018 · 3 comments
Assignees
Labels
editor-folding Editor code folding issues

Comments

@uday0408
Copy link

uday0408 commented Feb 3, 2018

  • VSCode Version: 1.19.3
  • OS Version: Mac OS X, 10.13
  • C# Extension version: Omnisharp 1.13.1

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:

  1. Apply formatting to following code
public static class Main
{
    public static int Foo(int x)
    {
        x = 5;
        #if false
        x++;
        #endif
        return x;
    }
}
  1. After formatting it looks like this:
public static class Main
{
    public static int Foo(int x)
    {
        x = 5;
#if false
        x++;
#endif
        return x;
    }
}
  1. This messes with folding of entire code!!

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

@vscodebot vscodebot bot added editor editor-autoindent Editor auto indentation issues labels Feb 3, 2018
@alexdima
Copy link
Member

alexdima commented Feb 5, 2018

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.

@aeschli
Copy link
Contributor

aeschli commented Feb 5, 2018

This issue was moved to dotnet/vscode-csharp#2008

@aeschli aeschli closed this as completed Feb 5, 2018
@aeschli
Copy link
Contributor

aeschli commented Feb 5, 2018

The request for language aware folding is #3422.

Moving to Omnisharp for deciding about whether the formatter needs to be changed or made configurable.

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 22, 2018
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-folding Editor code folding issues
Projects
None yet
Development

No branches or pull requests

3 participants