Skip to content
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

Slightly smarter input indentation #389

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

waf
Copy link
Owner

@waf waf commented Dec 13, 2024

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

Copy link

codecov bot commented Dec 13, 2024

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 ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant