Skip to content

Commit 20ab6c8

Browse files
committed
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.
1 parent 8c01464 commit 20ab6c8

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

pkg/gui/layout.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ package gui
22

33
import (
44
"github.com/jesseduffield/gocui"
5-
"github.com/jesseduffield/lazygit/pkg/gui/context"
65
"github.com/jesseduffield/lazygit/pkg/gui/types"
76
"github.com/samber/lo"
8-
"golang.org/x/exp/slices"
97
)
108

119
// layout is called for every screen re-render e.g. when the screen is resized
@@ -244,25 +242,6 @@ func (gui *Gui) onRepoViewReset() error {
244242
}
245243
}
246244

247-
gui.g.Mutexes.ViewsMutex.Lock()
248-
// add tabs to views
249-
for _, view := range gui.g.Views() {
250-
// if the view is in our mapping, we'll set the tabs and the tab index
251-
for _, values := range gui.viewTabMap() {
252-
index := slices.IndexFunc(values, func(tabContext context.TabView) bool {
253-
return tabContext.ViewName == view.Name()
254-
})
255-
256-
if index != -1 {
257-
view.Tabs = lo.Map(values, func(tabContext context.TabView, _ int) string {
258-
return tabContext.Tab
259-
})
260-
view.TabIndex = index
261-
}
262-
}
263-
}
264-
gui.g.Mutexes.ViewsMutex.Unlock()
265-
266245
return nil
267246
}
268247

pkg/gui/views.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import (
44
"fmt"
55

66
"github.com/jesseduffield/gocui"
7+
"github.com/jesseduffield/lazygit/pkg/gui/context"
78
"github.com/jesseduffield/lazygit/pkg/theme"
89
"github.com/samber/lo"
10+
"golang.org/x/exp/slices"
911
)
1012

1113
type viewNameMapping struct {
@@ -234,4 +236,20 @@ func (gui *Gui) configureViewProperties() {
234236

235237
gui.Views.Stash.TitlePrefix = ""
236238
}
239+
240+
for _, view := range gui.g.Views() {
241+
// if the view is in our mapping, we'll set the tabs and the tab index
242+
for _, values := range gui.viewTabMap() {
243+
index := slices.IndexFunc(values, func(tabContext context.TabView) bool {
244+
return tabContext.ViewName == view.Name()
245+
})
246+
247+
if index != -1 {
248+
view.Tabs = lo.Map(values, func(tabContext context.TabView, _ int) string {
249+
return tabContext.Tab
250+
})
251+
view.TabIndex = index
252+
}
253+
}
254+
}
237255
}

0 commit comments

Comments
 (0)