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
Codecov Report
Attention: Patch coverage is 34.28571% with 23 lines in your changes missing coverage. Please review.
Project coverage is 67.0%. Comparing base (
d65ec6f) to head (2c9ae3c). Report is 1 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| CSharpRepl/CSharpReplPromptCallbacks.cs | 34.2% | 14 Missing and 9 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #389 +/- ##
=======================================
- Coverage 67.2% 67.0% -0.2%
=======================================
Files 90 90
Lines 6719 6748 +29
Branches 915 930 +15
=======================================
+ Hits 4518 4525 +7
- Misses 1884 1898 +14
- Partials 317 325 +8
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.