diff options
-rw-r--r-- | app.go | 2 | ||||
-rw-r--r-- | ui/buffers.go | 22 | ||||
-rw-r--r-- | ui/ui.go | 4 |
3 files changed, 13 insertions, 15 deletions
@@ -673,7 +673,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) { Mergeable: true, }) case irc.SelfPartEvent: - app.win.RemoveBuffer(ev.Channel) + app.win.RemoveBuffer(netID, ev.Channel) delete(app.messageBounds, boundKey{netID, ev.Channel}) case irc.UserPartEvent: var body ui.StyledStringBuilder 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) { @@ -181,8 +181,8 @@ func (ui *UI) AddBuffer(netID, netName, title string) (i int, added bool) { return ui.bs.Add(netID, netName, title) } -func (ui *UI) RemoveBuffer(title string) { - _ = ui.bs.Remove(title) +func (ui *UI) RemoveBuffer(netID, title string) { + _ = ui.bs.Remove(netID, title) ui.memberOffset = 0 } |