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

Allow string code actions in Razor files #8837

Merged
merged 1 commit into from
Jun 19, 2023

Conversation

davidwengier
Copy link
Contributor

Fixes: An inate desire to have more code actions

@davidwengier davidwengier requested a review from a team as a code owner June 16, 2023 07:40
@@ -355,6 +355,15 @@ private static void CleanupSourceMappingStart(FormattingContext context, Range s
return;
}

// Parent.Parent.Parent is because the tree is
// ExplicitExpression -> ExplicitExpressionBody -> CSharpCodeBlock -> CSharpExpressionLiteral
if (owner is CSharpExpressionLiteralSyntax { Parent.Parent.Parent: CSharpExplicitExpressionSyntax explicitExpression } &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is required because without code actions, there was no real way to invoke ontype formatting in an explicit expression, so there was just no code to deal with them.

Comment on lines +174 to +176
if (collapsedEdit.NewText.Length == 0 &&
collapsedEdit.Range.Start.Line == collapsedEdit.Range.End.Line &&
collapsedEdit.Range.Start.Character == collapsedEdit.Range.End.Character)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change is required because otherwise the edit to remove the @ on @"goo" was being dropped. I've honestly no idea why we would have been filtering out empty edits, and can only guess that the intent was to filter out useless edits. No existing formatting tests break with this change, so we've got that going for us at least.

Copy link
Contributor

@allisonchou allisonchou left a comment

Choose a reason for hiding this comment

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

Awesome! Glad to see more code actions

@davidwengier davidwengier merged commit 9303883 into dotnet:main Jun 19, 2023
@davidwengier davidwengier deleted the StringLiteralCodeActions branch June 19, 2023 05:57
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.

2 participants