Register keyboard shortcuts on the Commit page

What does this MR do and why?

Rapid Diffs keyboard shortcuts were only wired on the merge request entry point. The Commit page never called initHotkeys(), so no shortcut worked there.

The commit entry now registers them. Three bindings stay out: next commit, previous commit and toggle-review are merge request specific, since their handlers read useMergeRequestVersions and write to useCodeReview, which carry no meaning on a commit. initHotkeys takes an optional mergeRequestShortcuts flag, defaulting to true so the merge request entry point is unchanged.

Related to #618786 (closed)

How to set up and validate locally

  1. Open any commit touching several files, for example /<group>/<project>/-/commit/<sha>.

  2. Click on an empty area of the page so no input has focus.

  3. Check these work:

    • j or ] for next file
    • k or [ for previous file
    • shift+d to toggle inline and side-by-side
    • select text inside a discussion, then r to quote reply
  4. Check these do nothing:

    • c (next commit)
    • x (previous commit)
    • v (toggle reviewed)
  5. Force Rapid Diffs with ?rapid_diffs=true: /<group>/<project>/-/merge_requests/<iid>/diffs?rapid_diffs=true

    Then v, c and x should work.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading