Add keybinding to focus secondary main view#5663
Open
blmerrett1 wants to merge 2 commits into
Open
Conversation
916ea37 to
ce3cfae
Compare
Author
|
Hi @jesseduffield , |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Description
Adds a
focusSecondaryViewkeybinding (default9) to focus the secondary main view directly, mirroring the existingfocusMainView(0).0focuses the primary main view and9the secondar, forming a natural pair, adjacent on the number row. The secondary panel title shows[9]whenshowPanelJumpsis enabled, and the binding is configurable viakeybinding.universal.focusSecondaryView.Motivation: Jump straight to staged
Reaching the secondary main view (for example the staged diff of a partially-staged file) otherwise takes multiple key presses, whereas the primary already has a direct key. While using lazygit I often found myself wanting to jump straight to staged changes. Beyond just staged vs unstaged, the pattern is also extensible to any lazygit view with a primary and secondary panel.
Fix: Main View
The first commit is a small, separable pre-existing fix:
SwitchToFocusedMainViewControllerwas only attached to the side panels, so the focus-main-view key (0) did nothing once a main view itself was focused. The keybinding still appears in the view title, so it seemed reasonable that it would still move focus. Attaching it to theNormal/NormalSecondarycontexts makes0(and the new9) work from within the main view, e.g. returning to the primary from the secondary. I isolated this change to its own commit with its own regression test.Testing
Integration tests added for both the fix (focus the primary from the secondary via the keybinding) and the feature(focus the secondary from a side panel, switch between the two main views, and no-op when no secondary view is visible). Manually verified with
showPanelJumpson and off, with a custom key, and with<disabled>. Keybinding tips page also verified.Requirements Check:
go generate ./...)