mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Refactor
This commit is contained in:
@ -5,8 +5,18 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
func GetWorktreeDisplayStrings(worktrees []*models.Worktree, isCurrent func(*models.Worktree) bool, isMissing func(*models.Worktree) bool) [][]string {
|
||||
return lo.Map(worktrees, func(worktree *models.Worktree, _ int) []string {
|
||||
return GetWorktreeDisplayString(
|
||||
isCurrent(worktree),
|
||||
isMissing(worktree),
|
||||
worktree)
|
||||
})
|
||||
}
|
||||
|
||||
func GetWorktreeDisplayString(isCurrent bool, isPathMissing bool, worktree *models.Worktree) []string {
|
||||
textStyle := theme.DefaultTextColor
|
||||
|
||||
@ -17,13 +27,13 @@ func GetWorktreeDisplayString(isCurrent bool, isPathMissing bool, worktree *mode
|
||||
currentColor = style.FgGreen
|
||||
}
|
||||
|
||||
icon := icons.IconForWorktree(worktree, false)
|
||||
icon := icons.IconForWorktree(false)
|
||||
if isPathMissing {
|
||||
textStyle = style.FgRed
|
||||
icon = icons.IconForWorktree(worktree, true)
|
||||
icon = icons.IconForWorktree(true)
|
||||
}
|
||||
|
||||
res := make([]string, 0, 3)
|
||||
res := []string{}
|
||||
res = append(res, currentColor.Sprint(current))
|
||||
if icons.IsIconEnabled() {
|
||||
res = append(res, textStyle.Sprint(icon))
|
||||
|
Reference in New Issue
Block a user