mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
Collapse/expand all files in tree
Co-authored-by: Stefan Haller <stefan@haller-berlin.de>
This commit is contained in:
committed by
Stefan Haller
parent
14a91d9829
commit
7bea41534b
@ -1,6 +1,7 @@
|
||||
package filetree
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
@ -160,3 +161,33 @@ func (self *CommitFileTreeViewModel) ToggleShowTree() {
|
||||
self.SetSelection(index)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *CommitFileTreeViewModel) CollapseAll() {
|
||||
selectedNode := self.GetSelected()
|
||||
|
||||
self.ICommitFileTree.CollapseAll()
|
||||
if selectedNode == nil {
|
||||
return
|
||||
}
|
||||
|
||||
topLevelPath := strings.Split(selectedNode.Path, "/")[0]
|
||||
index, found := self.GetIndexForPath(topLevelPath)
|
||||
if found {
|
||||
self.SetSelectedLineIdx(index)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *CommitFileTreeViewModel) ExpandAll() {
|
||||
selectedNode := self.GetSelected()
|
||||
|
||||
self.ICommitFileTree.ExpandAll()
|
||||
|
||||
if selectedNode == nil {
|
||||
return
|
||||
}
|
||||
|
||||
index, found := self.GetIndexForPath(selectedNode.Path)
|
||||
if found {
|
||||
self.SetSelectedLineIdx(index)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user