summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-10-19 11:22:33 +0200
committerRobin Jarry <robin@jarry.cc>2022-10-19 20:27:24 +0200
commit6eed15c579017099c31d73821e70bc363e0fe7b8 (patch)
treef13adf3f36dcf591050c267dca12432dc4054201
parentebcd6fcea1517b00153214e3284d6307809175f5 (diff)
downloadaerc-6eed15c579017099c31d73821e70bc363e0fe7b8.tar.gz
aerc-6eed15c579017099c31d73821e70bc363e0fe7b8.zip
dirtree: fix folder scrolling
Fix scrolling by correcting the index calculation. Fixes: https://todo.sr.ht/~rjarry/aerc/93 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net>
-rw-r--r--widgets/dirtree.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/widgets/dirtree.go b/widgets/dirtree.go
index eae2f7d1..68ff32f0 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)