1package presentation
2
3import (
4 "strings"
5
6 "github.com/jesseduffield/lazygit/pkg/commands/models"
7 "github.com/jesseduffield/lazygit/pkg/theme"
8 "github.com/samber/lo"
9)
10
11func GetSubmoduleListDisplayStrings(submodules []*models.SubmoduleConfig) [][]string {
12 return lo.Map(submodules, func(submodule *models.SubmoduleConfig, _ int) []string {
13 return getSubmoduleDisplayStrings(submodule)
14 })
15}
16
17func getSubmoduleDisplayStrings(s *models.SubmoduleConfig) []string {
18 name := s.Name
19 if s.ParentModule != nil {
20 count := 0
21 for p := s.ParentModule; p != nil; p = p.ParentModule {
22 count++
23 }
24 indentation := strings.Repeat(" ", count)
25 name = indentation + "- " + s.Name
26 }
27
28 return []string{theme.DefaultTextColor.Sprint(name)}
29}
30