Open mjbvz opened 5 years ago
Hi @sandy081
Is this likely to be implemented any time soon?
Not yet planned.
To help search discovery via https://github.com/microsoft/vscode/issues:
Other ways of phrasing the title include:
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:
Currently, the only way is to define the key in the package.json:
With this, the "override/Implement methods" can be assigned with a key:
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.
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
?
Scenario We support creating keybindings to trigger specific types of code actions or refactorings like so:
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
args
somewhere in the keybindings editorargs
in some way (possibly with a UX similar to the settings editor)args
/cc @misolori Since this would likely require some UX work /cc @kieferrm For general refactoring discoverability