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.
This commit is contained in:
Reto Brunner 2020-09-08 07:46:21 +02:00
parent 6ddd347b06
commit fe42beb3e4
1 changed files with 6 additions and 0 deletions

View File

@ -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 {