aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-15 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-15 20:20:20 +0100
commit302ef8cfa60d2d7c6236e1dd7821750e4e1e8a47 (patch)
tree0bd3082ad6e04c7008f9c4a443ed1abfc665cbdf
parentcleaner (diff)
downloadhardflip-302ef8cfa60d2d7c6236e1dd7821750e4e1e8a47.tar.gz
hardflip-302ef8cfa60d2d7c6236e1dd7821750e4e1e8a47.tar.bz2
hardflip-302ef8cfa60d2d7c6236e1dd7821750e4e1e8a47.tar.xz
hardflip-302ef8cfa60d2d7c6236e1dd7821750e4e1e8a47.tar.zst
hardflip-302ef8cfa60d2d7c6236e1dd7821750e4e1e8a47.zip
cleaner i guess
Diffstat (limited to '')
-rw-r--r--c_litems.go9
-rw-r--r--i_events.go12
2 files changed, 12 insertions, 9 deletions
diff --git a/c_litems.go b/c_litems.go
index 4aa21d6..86841ca 100644
--- a/c_litems.go
+++ b/c_litems.go
@@ -210,3 +210,12 @@ func (item *ItemsNode) get_next_level() *ItemsNode {
}
return nil
}
+
+func (litems *ItemsList) reset_id() {
+ if litems.head != nil {
+ litems.head.ID = 1
+ }
+ for ptr := litems.head; ptr != nil && ptr.next != nil; ptr = ptr.next {
+ ptr.next.ID = ptr.ID + 1
+ }
+}
diff --git a/i_events.go b/i_events.go
index ccc35b8..f1cf3c4 100644
--- a/i_events.go
+++ b/i_events.go
@@ -76,9 +76,7 @@ func i_list_follow_cursor(litems *ItemsList, ui *HardUI) {
func i_set_unfold(data *HardData, item *ItemsNode) {
delete(data.folds, item.Dirs)
- for ptr := data.litems.head; ptr != nil && ptr.next != nil; ptr = ptr.next {
- ptr.next.ID = ptr.ID + 1
- }
+ data.litems.reset_id()
}
func i_unfold_dir(data *HardData, item *ItemsNode) {
@@ -123,9 +121,7 @@ func i_set_fold(data *HardData, curr, start, end *ItemsNode) {
}
folds[curr.Dirs] = &tmp
- for ptr := data.litems.head; ptr != nil && ptr.next != nil; ptr = ptr.next {
- ptr.next.ID = ptr.ID + 1
- }
+ data.litems.reset_id()
}
func i_fold_dir(data *HardData, item *ItemsNode) {
@@ -200,9 +196,7 @@ func i_delete_dir(data *HardData) {
data.litems.last = curr.prev
data.litems.curr = curr.prev
}
- for ptr := data.litems.head; ptr != nil && ptr.next != nil; ptr = ptr.next {
- ptr.next.ID = ptr.ID + 1
- }
+ data.litems.reset_id()
if err := os.RemoveAll(dir_path); err != nil {
data.ui.s.Fini()
c_die("can't remove " + dir_path, err)