mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-09 13:47:11 +02:00
fix bug for combining directories with single child
This commit is contained in:
parent
a31db3df9c
commit
def68ddc8f
@ -157,10 +157,6 @@ func (s *StatusLineNode) GetPath() string {
|
|||||||
return s.Path
|
return s.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StatusLineNode) HasExactlyOneChild() bool {
|
|
||||||
return len(s.Children) == 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *StatusLineNode) Compress() {
|
func (s *StatusLineNode) Compress() {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
return
|
return
|
||||||
@ -174,10 +170,10 @@ func (s *StatusLineNode) compressAux() *StatusLineNode {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, child := range s.Children {
|
for i := range s.Children {
|
||||||
if child.HasExactlyOneChild() {
|
for s.Children[i].HasExactlyOneChild() {
|
||||||
grandchild := child.Children[0]
|
grandchild := s.Children[i].Children[0]
|
||||||
grandchild.Name = fmt.Sprintf("%s/%s", child.Name, grandchild.Name)
|
grandchild.Name = fmt.Sprintf("%s/%s", s.Children[i].Name, grandchild.Name)
|
||||||
s.Children[i] = grandchild
|
s.Children[i] = grandchild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,3 +184,7 @@ func (s *StatusLineNode) compressAux() *StatusLineNode {
|
|||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StatusLineNode) HasExactlyOneChild() bool {
|
||||||
|
return len(s.Children) == 1
|
||||||
|
}
|
||||||
|
@ -64,6 +64,23 @@ func TestCompress(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "dir3",
|
||||||
|
Path: "dir3",
|
||||||
|
Children: []*StatusLineNode{
|
||||||
|
{
|
||||||
|
Name: "dir3-1",
|
||||||
|
Path: "dir3/dir3-1",
|
||||||
|
Children: []*StatusLineNode{
|
||||||
|
{
|
||||||
|
File: &File{Name: "file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
|
Name: "file5",
|
||||||
|
Path: "dir3/dir3-1/file5",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
File: &File{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &File{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Name: "file1",
|
Name: "file1",
|
||||||
@ -95,6 +112,11 @@ func TestCompress(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "dir3/dir3-1/file5",
|
||||||
|
File: &File{Name: "file5", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
|
Path: "dir3/dir3-1/file5",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
File: &File{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
File: &File{Name: "file1", ShortStatus: "M ", HasUnstagedChanges: true},
|
||||||
Name: "file1",
|
Name: "file1",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user