mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
Fix: make isDescendentOfSelectedNodes work for the root item
The root item's path is ".", and the path of a file at top level is "./file". When using GetPath, this gives us "." and "file", respectively, and isDescendentOfSelectedNodes would return false for these. Working with the internal paths (i.e. without stripping the leading "./") fixes this.
This commit is contained in:
@@ -1221,14 +1221,14 @@ func normalisedSelectedNodes(selectedNodes []*filetree.FileNode) []*filetree.Fil
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isDescendentOfSelectedNodes(node *filetree.FileNode, selectedNodes []*filetree.FileNode) bool {
|
func isDescendentOfSelectedNodes(node *filetree.FileNode, selectedNodes []*filetree.FileNode) bool {
|
||||||
nodePath := node.GetPath()
|
nodePath := node.GetInternalPath()
|
||||||
|
|
||||||
for _, selectedNode := range selectedNodes {
|
for _, selectedNode := range selectedNodes {
|
||||||
if selectedNode.IsFile() {
|
if selectedNode.IsFile() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedNodePath := selectedNode.GetPath()
|
selectedNodePath := selectedNode.GetInternalPath()
|
||||||
|
|
||||||
if strings.HasPrefix(nodePath, selectedNodePath+"/") {
|
if strings.HasPrefix(nodePath, selectedNodePath+"/") {
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user