aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-09 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-09 20:20:20 +0100
commitba548cbc8e45b931aff88128705deb8116ab35ea (patch)
tree31a0ba1aafb6fd56bae35385f9f2c9d24ae1733e
parentin progress (diff)
downloadhardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.gz
hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.bz2
hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.xz
hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.tar.zst
hardflip-ba548cbc8e45b931aff88128705deb8116ab35ea.zip
delete fixed
-rw-r--r--c_lhosts.go16
-rw-r--r--i_events.go14
-rw-r--r--i_ui.go2
3 files changed, 15 insertions, 17 deletions
diff --git a/c_lhosts.go b/c_lhosts.go
index 74726d8..4041279 100644
--- a/c_lhosts.go
+++ b/c_lhosts.go
@@ -112,6 +112,15 @@ func (lhost *HostList) del(host *HostNode) {
}
return
}
+ if lhost.last == host {
+ ptr := lhost.head
+ for ptr.next != nil {
+ ptr = ptr.next
+ }
+ lhost.last = ptr
+ lhost.last.next = nil
+ return
+ }
ptr := lhost.head
for ptr.next != nil && ptr.next != host {
ptr = ptr.next
@@ -122,13 +131,6 @@ func (lhost *HostList) del(host *HostNode) {
for ptr := ptr.next; ptr != nil; ptr = ptr.next {
ptr.ID -= 1
}
- if lhost.last == host {
- ptr := lhost.head
- for ptr.next != nil {
- ptr = ptr.next
- }
- lhost.last = ptr
- }
}
// return the list node with the according id
diff --git a/i_events.go b/i_events.go
index 2484f28..4ea2a1a 100644
--- a/i_events.go
+++ b/i_events.go
@@ -87,12 +87,11 @@ func i_delete_host(data *HardData) {
if host == nil {
return
}
- // FIX: uncomment this after fix
- // file_path := data.data_dir + host.Parent.path() + host.Filename
- //
- // if err := os.Remove(file_path); err != nil {
- // c_die("can't remove " + file_path, err)
- // }
+ file_path := data.data_dir + host.Parent.path() + host.Filename
+
+ if err := os.Remove(file_path); err != nil {
+ c_die("can't remove " + file_path, err)
+ }
var tmp *ItemsNode
host.Parent.lhost.del(host)
if data.litems.curr != nil {
@@ -108,9 +107,6 @@ func i_delete_host(data *HardData) {
} else {
data.ui.sel_max = 0
}
- // FIX: segv if only one host
- // FIX: segv if del last host <- this is new, fuck
- // FIX: doesn't del the first one visually
}
// screen events such as keypresses
diff --git a/i_ui.go b/i_ui.go
index 7cdc515..82cfb49 100644
--- a/i_ui.go
+++ b/i_ui.go
@@ -549,7 +549,7 @@ func i_ui(data *HardData) {
i_bottom_text(*ui)
i_host_panel(data.ui, data.opts.Icon, data.litems)
i_info_panel(data.ui, data.litems)
- if data.ldirs.head.lhost.head == nil && data.ldirs.head.next == nil {
+ if data.litems.head == nil {
i_draw_zhosts_box(*ui)
}
if ui.mode == DELETE_MODE {