mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-08-24 10:13:41 -05:00
Assign the transient contexts' initial windows from the side panel config
The transient contexts (remoteBranches, subCommits, commitFiles) take
over the window of the context they are drilled into from, but until
then they carry a hardcoded initial window ("branches" or
"commits"). Under a gui.sidePanels config where those tabs aren't
their panel's first, no window of that name exists, leaving the
window-to-view map with entries for windows the layout never
produces. The previous commit made such entries harmless, but there's
no reason to have contexts point at nonexistent windows in the first
place; assign them the window hosting branches or commits instead,
which the config validation guarantees to exist.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
bf4f5827e7
commit
74a77e58be
@@ -125,4 +125,13 @@ func (gui *Gui) assignSidePanelWindows(contextTree *context.ContextTree) {
|
||||
ctx.SetWindowName(name)
|
||||
}
|
||||
}
|
||||
|
||||
// The transient contexts take over the window of the context they are
|
||||
// drilled into from, but they need a valid initial window before their
|
||||
// first use. Assign the window hosting branches or commits, respectively;
|
||||
// unlike e.g. remotes, those tabs can't be hidden, so their windows are
|
||||
// always part of the layout.
|
||||
contextTree.RemoteBranches.SetWindowName(contextTree.Branches.GetWindowName())
|
||||
contextTree.SubCommits.SetWindowName(contextTree.Branches.GetWindowName())
|
||||
contextTree.CommitFiles.SetWindowName(contextTree.LocalCommits.GetWindowName())
|
||||
}
|
||||
|
||||
@@ -28,3 +28,23 @@ func TestSidePanelLookupsCoverAllValidTabs(t *testing.T) {
|
||||
assert.Equal(t, want, sortedKeys(gui.sidePanelTabTitles()))
|
||||
assert.Equal(t, want, sortedKeys(sidePanelContexts(gui.contextTree())))
|
||||
}
|
||||
|
||||
// The transient contexts must end up in windows that exist under the configured
|
||||
// panel layout, or their views would be laid out for a window that is never
|
||||
// shown.
|
||||
func TestAssignSidePanelWindowsCoversTransientContexts(t *testing.T) {
|
||||
gui := NewDummyGui()
|
||||
gui.c.UserConfig().Gui.SidePanels = []config.SidePanel{
|
||||
{"worktrees", "branches", "remotes"},
|
||||
{"files"},
|
||||
{"tags", "commits"},
|
||||
{"stash"},
|
||||
}
|
||||
|
||||
contextTree := gui.contextTree()
|
||||
gui.assignSidePanelWindows(contextTree)
|
||||
|
||||
assert.Equal(t, "worktrees", contextTree.RemoteBranches.GetWindowName())
|
||||
assert.Equal(t, "worktrees", contextTree.SubCommits.GetWindowName())
|
||||
assert.Equal(t, "tags", contextTree.CommitFiles.GetWindowName())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user