-
Notifications
You must be signed in to change notification settings - Fork 234
Enable "toggle block style" refactor when there's no selection #3818
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
Enable "toggle block style" refactor when there's no selection #3818
Conversation
How to use the Graphite Merge QueueAdd the label graphite-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
|
I have signed the CLA! |
vinistock
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this is great. Let's just ensure we're not traversing the AST multiple times for discovering code actions and we should be good to ship
vinistock
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
|
Huh, I'm not sure why CI got stuck. @rolandcrosby-columntax could you please rebase to kick off CI again? |
7de9745 to
b64ba68
Compare
b64ba68 to
fd0deb9
Compare
|
@vinistock Done. Thanks for reviewing, and let me know if you need anything else to get this merged! |
Motivation
The "toggle block style" refactor action currently only works if there is a selection in the editor which covers a call node and its associated block. When there's no selection but the cursor is inside a block, it would be nice to be able to toggle the style of the block that the cursor is inside.
Implementation
CodeActionsrequest: add a quick check using@document.locate_nodeto conditionally offer the "toggle block style" action if the cursor is inside aBlockNodeCodeActionResolverequest: add a similar call to find the current block node when there's no selection. The actual rewrite also needs theCallNodeassociated with the block, and I couldn't figure out a good way to do this without adding a secondRubyDocument.locatecall. (When you calllocate_nodeto get the BlockNode, you don't get any reference to theCallNodethat theBlockNodeis attached to. You also can't just look for aCallNodecovering the cursor - that could return aCallNodethat's actually inside the block that you want to toggle.)Automated Tests
Added some expectation tests:
Manual Tests