[WIP] Keyboard shortcuts for expand & collapse diff
Review Request #10951 — Created March 12, 2020 and updated — Latest diff uploaded
This patch adds keyboard shortcuts to expand & collapse the diff in a review
request and in a diff fragment in a review. Expand is triggered by thee
key and collapse is triggered by thew
key (thec
key may seem more
natural, but it's taken already by another shortcut sow
was chosen for its
proximity to thee
key for ease of use between them).For the diff viewer, expand and collapse buttons are now tracked as anchors
inRB.DiffViewerPageView
. This allows us to find the next button on the
page from the currently selected anchor and trigger it when a keyboard
shortcut is used. Thee
andw
keys are added to the existing key
bindings mixin object to track those key presses and trigger the right
button.For diff fragments, there can only be one set of expand buttons and one
collapse button in any given fragment. If the fragment is focused, thee
andw
keys will trigger their respective expand and collapse buttons. This
is implemented by using the key bindings mixin inRB.DiffFragmentView
. The
shortcut to expand the fragment defaults to expanding the diff by 20 lines,
which is achieved by adding a modifier to desired expand button.
Manual testing & unit tests for the
e
andw
key events in both the diff
fragment and diff viewer.