From 56fce9e433a78547e2d92ebef92cab62eaa1c1a7 Mon Sep 17 00:00:00 2001 From: delthas Date: Mon, 15 Nov 2021 17:01:12 +0100 Subject: Fix part-ing a channel with duplicate name in other networks If there are multiple channels with the same name in several networks, we should part from the one from the correct network. --- ui/buffers.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'ui/buffers.go') diff --git a/ui/buffers.go b/ui/buffers.go index 3e13302..9dc26c2 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -277,19 +277,17 @@ func (bs *BufferList) Add(netID, netName, title string) (i int, added bool) { return len(bs.list) - 1, true } -func (bs *BufferList) Remove(title string) (ok bool) { - lTitle := strings.ToLower(title) - for i, b := range bs.list { - if strings.ToLower(b.title) == lTitle { - ok = true - bs.list = append(bs.list[:i], bs.list[i+1:]...) - if len(bs.list) <= bs.current { - bs.current-- - } - return - } +func (bs *BufferList) Remove(netID, title string) bool { + idx := bs.idx(netID, title) + if idx < 0 { + return false + } + + bs.list = append(bs.list[:idx], bs.list[idx+1:]...) + if len(bs.list) <= bs.current { + bs.current-- } - return + return true } func (bs *BufferList) AddLine(netID, title string, notify NotifyType, line Line) { -- cgit v1.2.3