commit df3ccf7
delthas
·
2023-07-05 16:01:13 +0000 UTC
parent 95c2e16
Refresh tab when it changes after deletion (e.g. PART)
1 files changed,
+17,
-0
+17,
-0
1@@ -381,26 +381,43 @@ func (bs *BufferList) Remove(netID, title string) bool {
2 if idx < 0 {
3 return false
4 }
5+ updated := bs.current == idx
6
7 bs.list = append(bs.list[:idx], bs.list[idx+1:]...)
8 if len(bs.list) <= bs.current {
9 bs.current--
10 }
11+ if updated {
12+ // Force refresh current buffer
13+ c := bs.current
14+ bs.current = -1
15+ bs.To(c)
16+ }
17 return true
18 }
19
20 func (bs *BufferList) RemoveNetwork(netID string) {
21+ updated := false
22 for idx := 0; idx < len(bs.list); idx++ {
23 b := &bs.list[idx]
24 if b.netID != netID {
25 continue
26 }
27+ if idx == bs.current {
28+ updated = true
29+ }
30 bs.list = append(bs.list[:idx], bs.list[idx+1:]...)
31 if len(bs.list) <= bs.current {
32 bs.current--
33 }
34 idx--
35 }
36+ if updated {
37+ // Force refresh current buffer
38+ c := bs.current
39+ bs.current = -1
40+ bs.To(c)
41+ }
42 }
43
44 func (bs *BufferList) mergeLine(former *Line, addition Line) (keepLine bool) {