CSharpRepl
CSharpRepl copied to clipboard
Slightly smarter input indentation
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