From 71e5e2d7951ae4c268e167aab32c35aeb7793d46 Mon Sep 17 00:00:00 2001 From: Koni Marti Date: Tue, 24 May 2022 19:12:35 +0200 Subject: 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 Acked-by: Robin Jarry --- widgets/aerc.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'widgets/aerc.go') 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)) + } } } -- cgit