You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Create custom widget for code actions (menu items). #152913
Lars Grammel (@lgrammel) What OS are you using VS Code in + can you give me a little more detail on how you're opening the code action widget? I was actually unaware that keybindings were ever shown in the Quick Fix.
Given this notion though, I definitely think it's helpful and can take a look into adding it in!
I'm using Mac OS Monterey 12.2 and I've invoked the menu through a shortcut provided by the JavaScript Assistant extension that I'm developing. It would apply to any user-defined shortcut for code actions as well, say in the following scenario with CTRL+CMD+M:
Thanks for creating this feature. I have been waiting for shortcut support in quick actions for some time.
It realy is my highlight from the latest VS Code update😊
Some feedback from trying out useCustomCodeActionMenu: it's no longer possible to select a list item using the keyboard. For example, with the old version I was able to select "Unwrap function call" simply by typing u:
Reacted by Vitaly
Reacted by heartacker, Justin Chen, Michael Schaufelberger and Lars Grammel
I have some feedback regarding the keyboard UX that has bothered me for a long time now 😅.
The old and the new widget both immediately select (but not activate) the option that is under the mouse cursor - even when opened with a hotkey (quick fix hotkey). This is really annoying if you want to quickly just accept the first quick fix in the list (e.g. adding an import), but coincidentally the mouse is over an option you don't want to choose and you either activate the wrong option, or have to scroll through all the options to the top first.
What I suggest is to ignore the mouse's position on the widget before the mouse is moved. This makes the mouse not interfere with whatever actions you are taking with the keyboard.
I will follow up with a small GIF if it's not clear.
Michael Schaufelberger (@michaelschufi) This fix is actually in Insiders at the moment! The mouse will no longer automatically select the option its hovering over on startup of the widget (although keyboard selection will still be on the first available code action). See #157694
Activity
Merge pull request #155666 from justschen/justin/CodeActionMenu-Widget
lgrammel commentedon Aug 4, 2022
Hi! I just tried out the new code action widget in 1.70.
Is there a plan to show the keyboard shortcuts as well (similar to the old code action context menu)?
This is helpful when there are different more detailed shortcuts for code actions, for example:
Old:

New:

The 2 shortcuts are not shown in the new version.
justschen commentedon Aug 4, 2022
Lars Grammel (@lgrammel) What OS are you using VS Code in + can you give me a little more detail on how you're opening the code action widget? I was actually unaware that keybindings were ever shown in the Quick Fix.
Given this notion though, I definitely think it's helpful and can take a look into adding it in!
lgrammel commentedon Aug 4, 2022
I'm using Mac OS Monterey 12.2 and I've invoked the menu through a shortcut provided by the JavaScript Assistant extension that I'm developing. It would apply to any user-defined shortcut for code actions as well, say in the following scenario with
CTRL+CMD+M:{ "key": "Ctrl+Cmd+M", "command": "editor.action.codeAction", "args": { "kind": "refactor.move", "apply": "never" } } { "key": "Ctrl+Alt+Up", "command": "editor.action.codeAction", "args": { "kind": "refactor.move.up", "apply": "ifSingle" } } { "key": "Ctrl+Alt+Down", "command": "editor.action.codeAction", "args": { "kind": "refactor.move.down", "apply": "ifSingle" } }justschen commentedon Aug 4, 2022
Gotcha! I think the reason some users have the shortcut details is because VS Code is using the native OS context menu.
Regardless, I'll go ahead and open an issue and take a look at it this iteration!
The issue can be found here: #157129
lgrammel commentedon Aug 4, 2022
Awesome, thank you!
HIKALU-Z commentedon Aug 5, 2022
it's really an awesome feature! it help me use my key bindings wehn refactor!
thank you!
Daellhin commentedon Aug 5, 2022
Thanks for creating this feature. I have been waiting for shortcut support in quick actions for some time.
It realy is my highlight from the latest VS Code update😊
OliverJAsh commentedon Aug 6, 2022
Some feedback from trying out
useCustomCodeActionMenu: it's no longer possible to select a list item using the keyboard. For example, with the old version I was able to select "Unwrap function call" simply by typingu:PabloLION commentedon Aug 10, 2022
Lars Grammel (@lgrammel), may I ask what "theme" you are using in the "New"?
Mine is not highlighting the current selection nor with keyboard nor with mouse after the cursor moving away. Like this

I tried the default light / dark them and neither shows the highlight.
lgrammel commentedon Aug 10, 2022
Pablo LION (@PabloLION) I was using Github Light Default when I took the screenshot.
michaelschufi commentedon Aug 11, 2022
I have some feedback regarding the keyboard UX that has bothered me for a long time now 😅.
The old and the new widget both immediately select (but not activate) the option that is under the mouse cursor - even when opened with a hotkey (quick fix hotkey). This is really annoying if you want to quickly just accept the first quick fix in the list (e.g. adding an import), but coincidentally the mouse is over an option you don't want to choose and you either activate the wrong option, or have to scroll through all the options to the top first.
What I suggest is to ignore the mouse's position on the widget before the mouse is moved. This makes the mouse not interfere with whatever actions you are taking with the keyboard.
I will follow up with a small GIF if it's not clear.
justschen commentedon Aug 11, 2022
Michael Schaufelberger (@michaelschufi) This fix is actually in Insiders at the moment! The mouse will no longer automatically select the option its hovering over on startup of the widget (although keyboard selection will still be on the first available code action). See #157694
justschen commentedon Aug 19, 2022
Some loose ends to potentially take a look at Matt Bierner (@mjbvz):
code fontto refactoring labels that have quotes around them (like Extract functionnewFunction)Refactor previewfrom the widget (Automatically show diff editor in refactor preview #158408)mjbvz commentedon Aug 30, 2022
Closing as this is shipping with the august release