From ba548cbc8e45b931aff88128705deb8116ab35ea Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 9 Jan 2024 20:20:20 +0100 Subject: delete fixed --- c_lhosts.go | 16 +++++++++------- i_events.go | 14 +++++--------- i_ui.go | 2 +- 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 { -- cgit v1.2.3