diff options
author | Reto Brunner <reto@labrat.space> | 2020-09-08 07:46:21 +0200 |
---|---|---|
committer | Reto Brunner <reto@labrat.space> | 2020-09-08 07:48:55 +0200 |
commit | fe42beb3e4ac00f07884880b7a6251c59fd04230 (patch) | |
tree | d2e5ab76fca265497819ba02a60e4ae7c559cad3 /widgets | |
parent | 6ddd347b06e840f064106a8181ae570e2d33d395 (diff) | |
download | aerc-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.
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/dirlist.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go index 3ed79ccf..aca14914 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 { |