Bug 315908 - [quick fix] Add shortcuts to quick fix proposals popup
Summary: [quick fix] Add shortcuts to quick fix proposals popup
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-06 14:29 EDT by Aaron Digulla CLA
Modified: 2010-06-17 08:32 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron Digulla CLA 2010-06-06 14:29:32 EDT
Build Identifier: I20100527-1700

Please add shortcuts (2-0) to the first 9 items of the quick fix menu (Ctrl-1). All of them should work with and without Ctrl.

Automatically assign "1" to the item which you used the last time (useful during code cleanup when you do a lot of the same stuff again and again).

Alternatively, assign alphabetic shortcuts based on the displayed names.

Reproducible: Always
Comment 1 Markus Keller CLA 2010-06-15 10:15:46 EDT
I agree that something like this could be helpful, but just assigning 1, 2, 3, etc. doesn't work. After you pressed Ctrl+1, the editor still has focus and accepts keys, so hijacking 1-9 would be confusing. And I don't want to reserve all the Ctrl+<Number> shortcuts for this. Maybe we could do something with mnemonics (Alt+1 .. Alt+9), but that wouldn't work on the Mac.

Note that many of the quick fixes and quick assists are already commands, which you can bind on Preferences > General > Keys, e.g. to "Ctrl+2, 1", "Ctrl+2, 2", etc. If you miss a command for a quick fix, please speak up.

The Quick Access popup (Ctrl+3) could also help you if you know you'll need the same command a few times in a row: Type "quick assist", invoke the command you want, and after that, "Ctrl+3, Enter" invokes the most recently used command.

I'll keep the bug open in case someone has a better idea for shortcuts.
Comment 2 Aaron Digulla CLA 2010-06-16 10:05:35 EDT
Can you at least map "Ctrl+1" twice to repeat the last quick fix?

Also mapping Ctrl+2...9 for the other action might work since the user could simply keep the key pressed. Since (s)he can see the Quick Fix open, the "stealing" would become more of a technical side effect (instead of an unexpected behavior).
Comment 3 Markus Keller CLA 2010-06-17 08:32:53 EDT
The second Ctrl+1 is already taken: When you press Ctrl+1 on a line with an error, but with the caret outside the error range, we automatically jump to the closest error and invoke quick fix there. A second Ctrl+1 takes you back to the original position and offers quick assists applicable to that position.

But maybe we're approaching this at the wrong level and should generalize this in the platform as a "Rerun last command" command, which just reruns the last command. This would also work in other scenarios where you want to "do the last thing again" (e.g. run a refactoring that does not have a shortcut, etc.). These could also be shown in the Ctrl+3 dialog in a new category "Previous Commands".

A "Rerun last command" command could e.g. be implemented via ICommandService#addExecutionListener(..). For quick fixes, this would not work out of the box because because the listener would just see the quick fix command itself, but I think it shouldn't be too hard to add the right events when executing quick fixes that already are commands.