summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorReto Brunner <reto@labrat.space>2020-09-08 07:46:21 +0200
committerReto Brunner <reto@labrat.space>2020-09-08 07:48:55 +0200
commitfe42beb3e4ac00f07884880b7a6251c59fd04230 (patch)
treed2e5ab76fca265497819ba02a60e4ae7c559cad3
parent6ddd347b06e840f064106a8181ae570e2d33d395 (diff)
downloadaerc-fe42beb3e4ac00f07884880b7a6251c59fd04230.tar.gz
dirlist: fix empty row if dir is added
There is a window where a new dir entry isn't yet in the dirlist.dir.
dirlist.ensureScroll however expected to always find a valid index.
Add a check so that we don't try to scroll to a -1 index.
-rw-r--r--widgets/dirlist.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 3ed79cc..aca1491 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -270,6 +270,12 @@ func (dirlist *DirectoryList) drawScrollbar(ctx *ui.Context, percentVisible floa
 
 func (dirlist *DirectoryList) ensureScroll(h int) {
 	selectingIdx := findString(dirlist.dirs, dirlist.selecting)
+	if selectingIdx < 0 {
+		// dir not found, meaning we are currently adding / removing a dir.
+		// we can simply ignore this until we get redrawn with the new
+		// dirlist.dir content
+		return
+	}
 
 	maxScroll := len(dirlist.dirs) - h
 	if maxScroll < 0 {
h=hlt&id=4cb6970d9d96d0adca78212f5f9b584499e37bb0'>^
6030d7e2 ^
9d27e966 ^
33352536 ^
6030d7e2 ^
33352536 ^
7dac9ade ^
80b6f47e ^
57628c0e ^
71eb22a5 ^
7a583220 ^
33352536 ^

ee9a9237 ^
33352536 ^







6030d7e2 ^
9d27e966 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
9d27e966 ^
6030d7e2 ^
9d27e966 ^
03d50cc8 ^
9d27e966 ^
ee9a9237 ^
33352536 ^

6030d7e2 ^
ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
9d27e966 ^
ee9a9237 ^
6030d7e2 ^

ee9a9237 ^
6030d7e2 ^
ee9a9237 ^
33352536 ^
03d50cc8 ^
6030d7e2 ^
03d50cc8 ^
ee9a9237 ^
33352536 ^


7a583220 ^
33352536 ^

6030d7e2 ^
57628c0e ^


e0ffdcd1 ^

f1eade72 ^
71eb22a5 ^
9b16f190 ^
6030d7e2 ^

4224ec81 ^
e0ffdcd1 ^
2a2a5b1e ^
9b16f190 ^
15ae0717 ^
a9d473e2 ^
f1eade72 ^
71eb22a5 ^
a9d473e2 ^




f1eade72 ^
71eb22a5 ^
a9d473e2 ^



ee9a9237 ^
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106