CSharpRepl icon indicating copy to clipboard operation
CSharpRepl copied to clipboard

Slightly smarter input indentation

Open waf opened this issue 10 months ago • 1 comments

Our smart indentation is surprisingly good for how simple it is, but it doesn't handle a few edge cases. One of those edge cases is curly braces inside strings like var a = "{"; -- that brace is detected as an opening brace which then messes up the indentation level. Additionally, a closing brace in a string can make the indentation go negative and crash the REPL.

We use the roslyn APIs for real formatting on e.g. semicolon press, but roslyn APIs won't add indentation for us, so we add it ourselves.

This PR improves the smart indentation to handle braces inside strings and comments. I'm sure it's not perfect and there are still many edge cases, but this improvement knocks out a few of those edge cases that people might commonly run into.

#378 and #379

waf avatar Dec 13 '24 18:12 waf