Skip to content

Allow viewing and editing commands with 'args' in the keybindings editor #84072

Open

Description

@mjbvz

Scenario
We support creating keybindings to trigger specific types of code actions or refactorings like so:

	{
		"key": "shift+ctrl+e",
		"command": "editor.action.codeAction",
		"args": {
			"kind": "refactor.extract",
			"preferred": true
		}
	}

#84033 added IntelliSense for creating keybindings like this in the json based keybindings editor. However at the moment, there is no way to properly view or create or edit keybindings that use args in the keybindings editor.

This is important because we are trying to make code actions (specifically refactorings) more discoverable. I believe that making it easier to setup keybindings for code actions would help with discoverability and also help push refactorings as a bigger part of user's workflows

Feature Request

  • Show the args somewhere in the keybindings editor
  • Let users edit the args in some way (possibly with a UX similar to the settings editor)
  • Let users create new keybindings with args

/cc @misolori Since this would likely require some UX work
/cc Kai Maetzel (@kieferrm) For general refactoring discoverability

Activity

  1. added
    keybindings
    keybindings-editor
    feature-request
    and removed
    keybindings
    on Nov 7, 2019
  2. robole commented on Nov 2, 2020

    @robole
    Contributor

    Hi Sandeep Somavarapu (@sandy081)

    Is this likely to be implemented any time soon?

  3. sandy081 commented on Nov 2, 2020

    @sandy081
    Member

    Not yet planned.

  4. xpe commented on Jan 27, 2021

    @xpe

    To help search discovery via https://github.com/microsoft/vscode/issues:

    Other ways of phrasing the title include:

    • View & edit args in the Keyboard Shortcuts editor
    • View and edit arguments in the Keyboard Shortcuts editor
    • Keyboard Shortcuts editor doesn't show custom arguments
    • Show custom arguments in Keyboard Shortcuts editor
  5. CsCherrYY commented on Nov 9, 2022

    @CsCherrYY
    Contributor

    It would be great if we can show the commands with args in the keybindings editor.

    redhat.java extension provides a lot of code actions, e.g., override/implement methods, generate getters/setters. However, unless user tries to find them via editor menu -> source action..., they can't find them. Although we also provide quick fixes via the light bulb, from the user feedback, we can also find a lot of users' complaints about missing source actions, which are usually already supported.

    Some of them try to find the source actions via keybindings editor but there is only an internal command (which is not helpful) can be found:
    image


    Currently, the only way is to define the key in the package.json:
    image

    With this, the "override/Implement methods" can be assigned with a key:
    image

    But that's not good enough, it's hard for a user to know the exact args(source.overrideMethods) of the source action. The keybindings editor containing the source actions would help a lot.

  6. CsCherrYY commented on Nov 14, 2022

    @CsCherrYY
    Contributor

    now the redhat.java extension supports a lot of source actions, and they usually have different kind property in args, the following table shows their kind value, the action title can be seen by users and default keybinding of the corresponding actions in IntelliJ IDEA.

    kind action title default keybinding in IntelliJ IDEA
    refactor.extract.function Extract to method Ctrl + Alt + M
    refactor.extract.constant Extract to constant Ctrl + Alt + C
    refactor.extract.variable Extract to local variable Ctrl + Alt + V
    refactor.extract.field Extract to field Ctrl + Alt + F
    refactor.inline Inline ... Ctrl + Alt + N
    refactor.move Move F6
    refactor.introduce.parameter Introduce parameter Ctrl + Alt + P
    source.organizeImports Organize Imports Ctrl + Alt + O
    source.generate.accessors Generate Getters and Setters Alt + insert
    source.generate.accessors Generate Getters Alt + insert
    source.generate.accessors Generate Setters Alt + insert
    source.generate.constructors Generate constructors Alt + insert
    source.generate.hashCodeEquals Generate hashCode() and equals() Alt + insert
    source.generate.toString Generate toString() Alt + insert
    source.generate.delegateMethods Generate Delegate Methods Alt + insert
    source.generate.finalModifiers Change modifiers to final where possible Alt + insert
    source.overrideMethods Override/Implement Methods Ctrl + O
    source.sortMembers Sort Members

    In IntelliJ IDEA, the generate source actions have a common entry "Alt+insert", and all the above keybindings are configurable in its setting wizard. It would be great if we could show and configure them in VS Code keybindings editor.

    Besides, one concern is if kind is concrete enough to be used to identify code actions. As shown above, we have three code actions that share the same kind source.generate.accessors and we use label and command to distinguish among them.

    If we show actions identified by kind and set them in the keybindings editor, when triggering, we will get a list containing all the code actions with the given kind. And it would be hard for users to just configure a specific code action(e.g, he wants to just set keybinding for Generate Getters and Setters, neither Generate Getters nor Generate Setters). Do we need another property (something like id) in type CodeActionItem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestkeybindings-editor

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions