about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/ui/tab.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/ui/tab.go b/lib/ui/tab.go
index ef9fcd8..27fb604 100644
--- a/lib/ui/tab.go
+++ b/lib/ui/tab.go
@@ -62,25 +62,31 @@ func (tabs *Tabs) invalidateChild(d Drawable) {
 }
 
 func (tabs *Tabs) Remove(content Drawable) {
-	match := false
+	indexToRemove := -1
 	for i, tab := range tabs.Tabs {
 		if tab.Content == content {
 			tabs.Tabs = append(tabs.Tabs[:i], tabs.Tabs[i+1:]...)
 			tabs.removeHistory(i)
-			match = true
+			indexToRemove = i
 			break
 		}
 	}
-	if !match {
+	if indexToRemove < 0 {
 		return
 	}
-	index, ok := tabs.popHistory()
-	if ok {
-		tabs.Select(index)
-		interactive, ok := tabs.Tabs[tabs.Selected].Content.(Interactive)
+	// only pop the tab history if the closing tab is selected
+	if indexToRemove == tabs.Selected {
+		index, ok := tabs.popHistory()
 		if ok {
-			interactive.Focus(true)
+			tabs.Select(index)
+			interactive, ok := tabs.Tabs[tabs.Selected].Content.(Interactive)
+			if ok {
+				interactive.Focus(true)
+			}
 		}
+	} else if indexToRemove < tabs.Selected {
+		// selected tab is now one to the left of where it was
+		tabs.Selected--
 	}
 	tabs.TabStrip.Invalidate()
 }
/profani-tty/blame/docs/profanity.1?id=4dbd8bbefac5ad695271541cc186fa3e1db984e8'>^
6f59a57b ^
3e92c60e ^


f4459f7f ^
3e92c60e ^



f4459f7f ^



034a9858 ^
10ca3e8c ^


f4459f7f ^
3e92c60e ^


a1ee1ad1 ^







3db7ae8d ^
6f59a57b ^
3e92c60e ^


4f4a2f33 ^
300b6072 ^
3e92c60e ^



270c88fc ^
6f59a57b ^
4dbd8bbe ^
f4459f7f ^
4dbd8bbe ^

d4892b29 ^
4dbd8bbe ^




03b75c83 ^
4dbd8bbe ^
4dbd8bbe ^
f8640019 ^
7d7f0ef5 ^
14c8f53f ^
4dbd8bbe ^

3e92c60e ^

7d7f0ef5 ^
4dbd8bbe ^
d4892b29 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78