Fix broken "Next Commit" shortcut "c"; conflicts with "Copy reference"
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
The "Move to next commit" shortcut c is very useful in the MR diff view. But currently, it conflicts with the "Copy merge request reference" shortcut c+r.
This results in the next commit shortcut not working most of the time. It works only when holding c down or pressing c twice in quick succession.
The Mousetrap library docs also say conflicts like this can occur:
It is important to note that Mousetrap can get very confused if you have a single key handler that uses the same key that a sequence starts with. This is because it can't tell if you are starting the sequence or if you are pressing that key on its own.
Steps to reproduce
- Navigate to a MR with multiple commits
- Go to the "Commits" tab and click on the latest commit (topmost in the list)
- Press the x key once. Observe how the previous commit navigation works fine.
- Press the c key once. Observe how nothing happens.
- Press c multiple times, with varying speed. Observe how it sometimes works properly.
Example
As an example, I picked some random MR. You can try out the shortcuts here:
What is the current bug behavior?
The "Next commit" navigation shortcut c does not work as intended, only working intermittently, on double presses, or when holding the key down.
What is the expected correct behavior?
The "Next commit" navigation shortcut c works immediately, when pressing they key once and every time (unless you're already at the last commit).
Output of checks
This bug happens on GitLab.com
Possible fixes
Option 1 – Less effort, higher outside impact
Change out one of the keybinds.
Preferably the "Copy reference" keybind should be changed out; since the commit navigation keybinds are next to each other on the keyboard, it would be odd to move one of them. Next to xc is also v, which marks a file as viewed in the diff view.
The relevant keybinds are defined here:
-
MR_COMMITS_NEXT_COMMIT:'c' -
ISSUABLE_COPY_REF:'c r'
There would also be a documentation change, since currently the keybinds help view (opened with ?) shows the "Copy reference" shortcut as being unified for work items and MRs.
Option 2 – More effort, lower outside impact
Disable the "Copy reference" keybind in the MR commit-based diff view
This would be preferred to option 1. Since no shortcuts are changed, user's won't need to un-learn any muscle memory they might already have.
The keybind is activated in shortcuts_issuable.js.