1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-07 22:02:56 +03:00

many more generics

This commit is contained in:
Jesse Duffield
2022-03-19 19:12:58 +11:00
parent bf4f06ab4e
commit 1b75ed3740
31 changed files with 278 additions and 320 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"strings"
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/i18n"
@@ -14,14 +15,10 @@ import (
var branchPrefixColorCache = make(map[string]style.TextStyle)
func GetBranchListDisplayStrings(branches []*models.Branch, fullDescription bool, diffName string, tr *i18n.TranslationSet) [][]string {
lines := make([][]string, len(branches))
for i := range branches {
diffed := branches[i].Name == diffName
lines[i] = getBranchDisplayStrings(branches[i], fullDescription, diffed, tr)
}
return lines
return slices.Map(branches, func(branch *models.Branch) []string {
diffed := branch.Name == diffName
return getBranchDisplayStrings(branch, fullDescription, diffed, tr)
})
}
// getBranchDisplayStrings returns the display string of branch