1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03: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

@ -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
}
}
}
}