mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-08-28 10:15:32 -05:00
Replace the hard-coded side panel order, tab groupings, and window assignments with values resolved from the gui.sidePanels config. The panel order (SideWindows and the layout boxes), the tab strips (viewTabMap), the per-context window names, each window's default view, and the jump-label groups all now come from the config rather than from five separate hard-coded lists. A panel's window name is the name of its first tab, and panels not listed in the config get their own window name so their views stay hidden instead of overlapping a visible panel. Three small lookups translate config names into views, tab titles, and contexts; a test keeps them in sync with the set of valid names. The lookups are split this way (rather than one resolver) because configureViewProperties runs before the context tree exists, so the title/view lookups must not depend on it. The config is applied to a repo's contexts via applySidePanelConfig on every repo entry, including the cached-repo path: a repo's per-repo config can differ from the previously visited one's, so each repo's contexts must be (re)assigned from its own config rather than kept from when they were first built. With the default config this reproduces today's layout exactly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
831 B
Go
31 lines
831 B
Go
package gui
|
|
|
|
import (
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/config"
|
|
"github.com/samber/lo"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func sortedKeys[V any](m map[string]V) []string {
|
|
keys := lo.Keys(m)
|
|
sort.Strings(keys)
|
|
return keys
|
|
}
|
|
|
|
// The three lookups that translate gui.sidePanels names into views, titles, and
|
|
// contexts must each cover exactly the set of valid names, or a config that uses
|
|
// a name missing from one of them would hit a nil lookup at runtime.
|
|
func TestSidePanelLookupsCoverAllValidTabs(t *testing.T) {
|
|
want := lo.Uniq(config.ValidSidePanelTabs)
|
|
sort.Strings(want)
|
|
|
|
gui := NewDummyGui()
|
|
|
|
assert.Equal(t, want, sortedKeys(sidePanelViewNames))
|
|
assert.Equal(t, want, sortedKeys(gui.sidePanelTabTitles()))
|
|
assert.Equal(t, want, sortedKeys(sidePanelContexts(gui.contextTree())))
|
|
}
|