mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-06-20 01:19:23 +02:00
Clear tab strips on views that are no longer tabs
The tab-assignment loop only ever set a view's tabs; it never cleared them. That was fine when the groupings were fixed, but with gui.sidePanels a config reload can turn a tab into a standalone panel, and the old tab strip would linger on its title. Index the tab strips by view name and assign to every view, so views that dropped out of a multi-tab panel get their tabs cleared. No change for a given config; this only matters across a reload. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+21
-14
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/samber/lo"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type viewNameMapping struct {
|
||||
@@ -249,19 +248,27 @@ func (gui *Gui) configureViewProperties() {
|
||||
gui.Views.Main.TitlePrefix = ""
|
||||
}
|
||||
|
||||
for _, view := range gui.g.Views() {
|
||||
// if the view is in our mapping, we'll set the tabs and the tab index
|
||||
for _, values := range gui.viewTabMap() {
|
||||
index := slices.IndexFunc(values, func(tabContext context.TabView) bool {
|
||||
return tabContext.ViewName == view.Name()
|
||||
})
|
||||
|
||||
if index != -1 {
|
||||
view.Tabs = lo.Map(values, func(tabContext context.TabView, _ int) string {
|
||||
return tabContext.Tab
|
||||
})
|
||||
view.TabIndex = index
|
||||
}
|
||||
// Index the tab strips by view so we can both set them on views that are
|
||||
// part of a multi-tab panel and clear them on views that no longer are
|
||||
// (which matters when the config is reloaded and a tab becomes a standalone
|
||||
// panel).
|
||||
type viewTabs struct {
|
||||
tabs []string
|
||||
index int
|
||||
}
|
||||
tabsByView := map[string]viewTabs{}
|
||||
for _, values := range gui.viewTabMap() {
|
||||
labels := lo.Map(values, func(tabContext context.TabView, _ int) string {
|
||||
return tabContext.Tab
|
||||
})
|
||||
for index, tabContext := range values {
|
||||
tabsByView[tabContext.ViewName] = viewTabs{tabs: labels, index: index}
|
||||
}
|
||||
}
|
||||
|
||||
for _, view := range gui.g.Views() {
|
||||
vt := tabsByView[view.Name()]
|
||||
view.Tabs = vt.tabs
|
||||
view.TabIndex = vt.index
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user