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

Address cases where brace matching wasn't working for string quotes. #72233

Merged
merged 5 commits into from
Feb 22, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Feb 22, 2024

Fixes #62571

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 22, 2024 18:33
if (token.Kind() is not SyntaxKind.InterpolatedStringStartToken and
not SyntaxKind.InterpolatedVerbatimStringStartToken and
not SyntaxKind.StringLiteralToken and
not SyntaxKind.IdentifierToken)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prior logic was too much syntax tree based. this made it fall over when the tree wasn't well formed (like just having a naked $ in an expression).

The fix is to smartly moved before those characters. We then know we must have a string (since we have a $ and we know the user is typing "). We then use the existing helpers to then ask "is this a legal place for such a string".

Importantly, we're only looking at the tree prior to the current token we're writing. we're not trying to examine the in-progress token itself directly.

Copy link
Member

@sharwell sharwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest manually verifying that this does not interfere with typing an interpolated raw string in the editor.

@DoctorKrolic
Copy link
Contributor

Fixes #62571 if I understand this correctly

@CyrusNajmabadi
Copy link
Member Author

CyrusNajmabadi commented Feb 22, 2024

Suggest manually verifying that this does not interfere with typing an interpolated raw string in the editor.

Have done so.

@CyrusNajmabadi CyrusNajmabadi merged commit 8f67d64 into dotnet:main Feb 22, 2024
25 of 27 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the stringInterpolation branch February 22, 2024 20:53
@jjonescz jjonescz added this to the 17.10 P2 milestone Feb 27, 2024
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.

Auto-quotes and "$" operator problem
4 participants