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

better appearance for reverse attribute

This commit is contained in:
Jesse Duffield
2022-04-15 10:56:49 +10:00
parent 6a153acc8f
commit 00afa30ebf
7 changed files with 35 additions and 37 deletions

View File

@ -1,7 +1,6 @@
package presentation
import (
"fmt"
"strings"
"github.com/jesseduffield/lazygit/pkg/commands/models"
@ -17,11 +16,12 @@ const (
COLLAPSED_ARROW = "►"
)
// keeping these here as individual constants in case later on people want the old tree shape
const (
INNER_ITEM = "├─ "
LAST_ITEM = "└─ "
NESTED = " "
NOTHING = " "
INNER_ITEM = " "
LAST_ITEM = " "
NESTED = " "
NOTHING = " "
)
func RenderFileTree(
@ -77,24 +77,20 @@ func renderAux(
isRoot := depth == -1
renderLineWithPrefix := func() string {
return prefix + renderLine(s, depth)
}
if s.IsLeaf() {
if isRoot {
return []string{}
}
return []string{renderLineWithPrefix()}
return []string{prefix + renderLine(s, depth)}
}
if collapsedPaths.IsCollapsed(s.GetPath()) {
return []string{fmt.Sprintf("%s %s", renderLineWithPrefix(), COLLAPSED_ARROW)}
return []string{prefix + COLLAPSED_ARROW + " " + renderLine(s, depth)}
}
arr := []string{}
if !isRoot {
arr = append(arr, fmt.Sprintf("%s %s", renderLineWithPrefix(), EXPANDED_ARROW))
arr = append(arr, prefix+EXPANDED_ARROW+" "+renderLine(s, depth))
}
newPrefix := prefix

View File

@ -53,12 +53,12 @@ func TestRenderFileTree(t *testing.T) {
},
expected: toStringSlice(
`
dir1
dir2
├─ dir2
├─ M file3
└─ M file4
└─ M file5
dir1
dir2
dir2
M file3
M file4
M file5
M file1
`,
),
@ -112,12 +112,12 @@ func TestRenderCommitFileTree(t *testing.T) {
},
expected: toStringSlice(
`
dir1
dir2
├─ dir2
├─ D file3
└─ M file4
└─ M file5
dir1
dir2
dir2
D file3
M file4
M file5
M file1
`,
),