Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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