aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-05-24 19:12:35 +0200
committerRobin Jarry <robin@jarry.cc>2022-05-31 14:32:30 +0200
commit71e5e2d7951ae4c268e167aab32c35aeb7793d46 (patch)
tree4568aedb6ecc8f18b736da220eca3c9a797d0324 /widgets
parent62982a9a679e667b7a1b0e7be1adfa3561c7eac4 (diff)
downloadaerc-71e5e2d7951ae4c268e167aab32c35aeb7793d46.tar.gz
ui: check bounds before drawing dialog
Check bounds before drawing a dialog window to avoid a panic when resizing the terminal window. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/aerc.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 0b4e36dd..83391807 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -181,8 +181,9 @@ func (aerc *Aerc) Focus(focus bool) {
func (aerc *Aerc) Draw(ctx *ui.Context) {
aerc.grid.Draw(ctx)
if aerc.dialog != nil {
- aerc.dialog.Draw(ctx.Subcontext(4, ctx.Height()/2-2,
- ctx.Width()-8, 4))
+ if w, h := ctx.Width(), ctx.Height(); w > 8 && h > 4 {
+ aerc.dialog.Draw(ctx.Subcontext(4, h/2-2, w-8, 4))
+ }
}
}