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 the Introduce local code action to run in code blocks #8830

Merged
merged 1 commit into from
Jun 16, 2023

Conversation

davidwengier
Copy link
Contributor

@davidwengier davidwengier commented Jun 15, 2023

Fixes #8578

TL;DR: I added 4 tests per line of code, and I expect everyone of you to do the same from now on! 😛

This isn't perfect because cursor position after the code action can be questionable, and there is no way for us to trigger a rename of the introduced local after the code action executes, but neither of those things are possible to make any better with the current LSP spec and client implementations, so here we are. I basically just played around with this in VS with all of the possibilities I could think of, and couldn't break it, so I figure its better than not having the code action available.

Looks like this:
RazorIntroduceLocal

@davidwengier davidwengier requested a review from a team as a code owner June 15, 2023 06:29
@@ -76,7 +76,7 @@ internal static class CodeActionExtensions

if (!isOnAllowList)
{
razorCodeAction.Title = "(Exp) " + razorCodeAction.Title;
razorCodeAction.Title = $"(Exp) {razorCodeAction.Title} ({razorCodeAction.Name})";
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 is unrelated, but when experimenting with code actions, its handy to know what Roslyn calls the action so we know what to add to the allow list.

@davidwengier davidwengier merged commit 460016c into dotnet:main Jun 16, 2023
@davidwengier davidwengier deleted the IntroduceLocal branch June 16, 2023 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants