From 6eed15c579017099c31d73821e70bc363e0fe7b8 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Wed, 19 Oct 2022 11:22:33 +0200 Subject: [PATCH] dirtree: fix folder scrolling Fix scrolling by correcting the index calculation. Fixes: https://todo.sr.ht/~rjarry/aerc/93 Signed-off-by: Koni Marti Tested-by: Inwit --- widgets/dirtree.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/widgets/dirtree.go b/widgets/dirtree.go index eae2f7d..68ff32f 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -82,9 +82,9 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) { textWidth = 0 } - rowNr := 0 for i, node := range dt.list { - if i < dt.Scroll() || !isVisible(node) { + rowNr := dt.countVisible(dt.list[:i]) + if rowNr < dt.Scroll() || !isVisible(node) { continue } row := rowNr - dt.Scroll() @@ -93,7 +93,6 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) { } name := dt.displayText(node) - rowNr++ dirStyle := []config.StyleObject{} path := dt.getDirectory(node)