-
Notifications
You must be signed in to change notification settings - Fork 677
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
Auto-indentation on ENTER only works in {
braced }
blocks
#5889
Comments
Maybe this could be brought up at the LSP meeting since we were previously requesting a new LSP API. This has come up a few times before and it seemed to be contingent on microsoft/vscode#13960 being implemented. |
Yes thats my plan too. |
Sorry if I misunderstood, but I believe this has no dependency on virtual space. |
@geekley To be fair to the C# extension, your scenarios fail in ts/js with FormatOnType disabled. Which makes sense because indentation is currently determined based on open brackets and they have a similar set of brackets. JS/TS exampleclass A {
// CORRECT: Auto-indented here
l = () =>
// BAD: Should probably increase indentation here
f(false);
// WRONG: Did not decrease indentation
f(arg) {
// CORRECT: Auto-indented here
if (b) {
// CORRECT: Auto-indented here
}
if (b)
// WRONG: Did not increase indentation
this.f(!b);
// WRONG: Did not decrease indentation
else
// WRONG: Did not increase indentation
this.f(b);
// WRONG: Did not decrease indentation
for (; b; b = !b)
// WRONG: Did not increase indentation
this.f(b);
// WRONG: Did not decrease indentation
while (b)
// WRONG: Did not increase indentation
this.f(b = !b);
// WRONG: Did not decrease indentation
}
} |
Ah, actually I see that geekley had FormatOnType enabled. JS/TS does much better in that scenario. O# doesn't perform any formatting on Enter. Which brings me to this old PR which is where I remembered the discussion around virtual space. |
You pinged someone else lol. Yes, I just tested here and you're right. Interesting. So that behavior is provided by a formatter? It seems JS/TS completely ignores But I believe VSCode extensions can still provide this independently of |
Environment data
VS Code version: 1.79.2
⚠️ Actually in this extension which is a fork of the official extension; but presumably it happens here too (please confirm).
C# Extension version: 1.25.7
OmniSharp using mono: 6.12.0
Dotnet Information
Settings
Steps to reproduce
"editor.autoIndent": "full"
is set for C#.editorconfig
with:A.cs
file on VSCodeExpected behavior
It should auto-add indentation properly when you press ENTER, as described in the code above.
Actual behavior
Indentation is as described above, which gives you a really bad coding experience (specially if you indent with spaces).
Additional context
Note that when you hover the folding regions, only the braces generate folding. There is no folding for non-braced statements like
if
,for
, etc. This could be related to why the editor is not indenting correctly. But it's also happening on the function with expression body despite it having folding, so maybe not.I don't know if this should be implemented through language defined brackets, onEnterRules or indentationRules. In any case, if you want to do a "smart" analysis, you could probably improve indentation even inside a switch block, so after a "top-level"
break
,continue
,goto
orreturn
statement, it would revert to label indentation.The text was updated successfully, but these errors were encountered: