[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 thewkey (theckey may seem more
natural, but it's taken already by another shortcut sowwas chosen for its
proximity to theekey 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. Theeandwkeys 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
andwkeys 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
eandwkey events in both the diff
fragment and diff viewer.