summaryrefslogtreecommitdiffstats
path: root/pkg/gui/filetree
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/gui/filetree')
-rw-r--r--pkg/gui/filetree/inode.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/pkg/gui/filetree/inode.go b/pkg/gui/filetree/inode.go
index 7c8b9fb75..48cdc3be3 100644
--- a/pkg/gui/filetree/inode.go
+++ b/pkg/gui/filetree/inode.go
@@ -1,8 +1,6 @@
package filetree
-import (
- "sort"
-)
+import "github.com/jesseduffield/generics/slices"
type INode interface {
IsNil() bool
@@ -27,19 +25,17 @@ func sortChildren(node INode) {
return
}
- children := node.GetChildren()
- sortedChildren := make([]INode, len(children))
- copy(sortedChildren, children)
+ sortedChildren := slices.Clone(node.GetChildren())
- sort.Slice(sortedChildren, func(i, j int) bool {
- if !sortedChildren[i].IsLeaf() && sortedChildren[j].IsLeaf() {
+ slices.SortFunc(sortedChildren, func(a, b INode) bool {
+ if !a.IsLeaf() && b.IsLeaf() {
return true
}
- if sortedChildren[i].IsLeaf() && !sortedChildren[j].IsLeaf() {
+ if a.IsLeaf() && !b.IsLeaf() {
return false
}
- return sortedChildren[i].GetPath() < sortedChildren[j].GetPath()
+ return a.GetPath() < b.GetPath()
})
// TODO: think about making this in-place