aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-11-07 22:31:23 +0100
committerRobin Jarry <robin@jarry.cc>2022-11-09 21:42:50 +0100
commit47a0f7d8e88ef47a127f42113e28f053c6ff04b8 (patch)
treeb89a85b6bf3b45e28413a7a450d08efbb25df068 /widgets
parent650e00972d036014530594bbd781579166889a5e (diff)
downloadaerc-47a0f7d8e88ef47a127f42113e28f053c6ff04b8.tar.gz
dirtree: prevent panic when no folder is found
Prevent crash when no folder is found. Fixes: https://todo.sr.ht/~rjarry/aerc/100 Fixes: https://todo.sr.ht/~rjarry/aerc/101 Signed-off-by: Koni Marti <koni.marti@gmail.com> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/dirlist.go2
-rw-r--r--widgets/dirtree.go2
2 files changed, 2 insertions, 2 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index 70550394..0f8431e9 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -131,7 +131,7 @@ func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
dirlist.spinner.Stop()
dirlist.Invalidate()
if done != nil {
- done(dirs)
+ done(dirlist.dirs)
}
}
})
diff --git a/widgets/dirtree.go b/widgets/dirtree.go
index 3e419d47..f475255f 100644
--- a/widgets/dirtree.go
+++ b/widgets/dirtree.go
@@ -59,7 +59,7 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) {
}
n := dt.countVisible(dt.list)
- if n == 0 {
+ if n == 0 || dt.listIdx < 0 {
style := dt.UiConfig("").GetStyle(config.STYLE_DIRLIST_DEFAULT)
ctx.Printf(0, 0, style, dt.UiConfig("").EmptyDirlist)
return