~sircmpwn/aerc

fe42beb3e4ac00f07884880b7a6251c59fd04230 — Reto Brunner a month ago 6ddd347
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.
1 files changed, 6 insertions(+), 0 deletions(-)

M widgets/dirlist.go
M widgets/dirlist.go => widgets/dirlist.go +6 -0
@@ 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 {