1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-25 12:24:47 +02:00

Set tab titles after reloading user config

This ensures that tab titles are updated to the new language when changing the
language in the config while lazygit is running.
This commit is contained in:
Stefan Haller 2025-03-05 21:17:43 +01:00
parent 8c014641d1
commit 20ab6c8cc8
2 changed files with 18 additions and 21 deletions

View File

@ -2,10 +2,8 @@ package gui
import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/context"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/samber/lo"
"golang.org/x/exp/slices"
)
// layout is called for every screen re-render e.g. when the screen is resized
@ -244,25 +242,6 @@ func (gui *Gui) onRepoViewReset() error {
}
}
gui.g.Mutexes.ViewsMutex.Lock()
// add tabs to views
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
}
}
}
gui.g.Mutexes.ViewsMutex.Unlock()
return nil
}

View File

@ -4,8 +4,10 @@ import (
"fmt"
"github.com/jesseduffield/gocui"
"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 {
@ -234,4 +236,20 @@ func (gui *Gui) configureViewProperties() {
gui.Views.Stash.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
}
}
}
}