diff --git a/pkg/gui/context/list_renderer.go b/pkg/gui/context/list_renderer.go index b8d036778..35e0b26ef 100644 --- a/pkg/gui/context/list_renderer.go +++ b/pkg/gui/context/list_renderer.go @@ -1,6 +1,7 @@ package context import ( + "fmt" "strings" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -9,6 +10,10 @@ import ( "golang.org/x/exp/slices" ) +func formatListSectionHeader(label string) string { + return fmt.Sprintf("--- %s ---", label) +} + type NonModelItem struct { // Where in the model this should be inserted Index int diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go index a66c720c9..034b2434e 100644 --- a/pkg/gui/context/local_commits_context.go +++ b/pkg/gui/context/local_commits_context.go @@ -1,7 +1,6 @@ package context import ( - "fmt" "log" "strings" "sync/atomic" @@ -72,7 +71,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext { if c.Model().WorkingTreeStateAtLastCommitRefresh.Rebasing { result = append(result, &NonModelItem{ Index: 0, - Content: fmt.Sprintf("--- %s ---", c.Tr.PendingRebaseTodosSectionHeader), + Content: formatListSectionHeader(c.Tr.PendingRebaseTodosSectionHeader), }) } @@ -91,7 +90,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext { c.Tr.PendingRevertsSectionHeader) result = append(result, &NonModelItem{ Index: firstCherryPickOrRevertTodo, - Content: fmt.Sprintf("--- %s ---", label), + Content: formatListSectionHeader(label), }) } @@ -104,7 +103,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext { } result = append(result, &NonModelItem{ Index: firstRealCommit, - Content: fmt.Sprintf("--- %s ---", c.Tr.CommitsSectionHeader), + Content: formatListSectionHeader(c.Tr.CommitsSectionHeader), }) } diff --git a/pkg/gui/context/menu_context.go b/pkg/gui/context/menu_context.go index 9feef1e4c..8129aa420 100644 --- a/pkg/gui/context/menu_context.go +++ b/pkg/gui/context/menu_context.go @@ -198,7 +198,7 @@ func (self *MenuViewModel) GetNonModelItems() []*NonModelItem { result = append(result, &NonModelItem{ Index: i, Column: 1, - Content: style.FgGreen.SetBold().Sprintf("--- %s ---", menuItem.Section.Title), + Content: style.FgGreen.SetBold().Sprint(formatListSectionHeader(menuItem.Section.Title)), }) prevSection = menuItem.Section } diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go index 4e05c9594..b0bcee30a 100644 --- a/pkg/gui/context/sub_commits_context.go +++ b/pkg/gui/context/sub_commits_context.go @@ -1,7 +1,6 @@ package context import ( - "fmt" "time" "github.com/jesseduffield/lazygit/pkg/commands/git_commands" @@ -90,7 +89,7 @@ func NewSubCommitsContext( } result = append(result, &NonModelItem{ Index: upstreamIdx, - Content: fmt.Sprintf("--- %s ---", c.Tr.DivergenceSectionHeaderRemote), + Content: formatListSectionHeader(c.Tr.DivergenceSectionHeaderRemote), }) _, localIdx, found := lo.FindIndexOf( @@ -100,7 +99,7 @@ func NewSubCommitsContext( } result = append(result, &NonModelItem{ Index: localIdx, - Content: fmt.Sprintf("--- %s ---", c.Tr.DivergenceSectionHeaderLocal), + Content: formatListSectionHeader(c.Tr.DivergenceSectionHeaderLocal), }) }