aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJason Stewart <support@eggplantsd.com>2022-09-26 11:11:49 -0400
committerRobin Jarry <robin@jarry.cc>2022-09-26 17:32:00 +0200
commit27978a859b279360b28240a62541849ad6bba39f (patch)
tree75322bcf45cd906e4eb4c65e676f4a5c9fc18195 /lib
parent4c3565653ab504166f9b8ecc1a44f6aa17f9f6e6 (diff)
downloadaerc-27978a859b279360b28240a62541849ad6bba39f.tar.gz
ui: avoid panic when terminal window is shrunk
When using a tiling window manager, aerc terminal dimensions may be greatly reduced after a new window has been created by :open. When the ui attempts to render to formerly-valid coordinates, SetCell & Printf may panic. Replace panic() with no-op in both functions to prevent aerc from crashing after a window shrink. Signed-off-by: Jason Stewart <support@eggplantsd.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r--lib/ui/context.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/ui/context.go b/lib/ui/context.go
index 859dab71..12d65bbf 100644
--- a/lib/ui/context.go
+++ b/lib/ui/context.go
@@ -56,7 +56,8 @@ func (ctx *Context) Subcontext(x, y, width, height int) *Context {
func (ctx *Context) SetCell(x, y int, ch rune, style tcell.Style) {
width, height := ctx.viewport.Size()
if x >= width || y >= height {
- panic(fmt.Errorf("Attempted to draw outside of context"))
+ // no-op when dims are inadequate
+ return
}
crunes := []rune{}
ctx.viewport.SetContent(x, y, ch, crunes, style)
@@ -68,7 +69,8 @@ func (ctx *Context) Printf(x, y int, style tcell.Style,
width, height := ctx.viewport.Size()
if x >= width || y >= height {
- panic(fmt.Errorf("Attempted to draw outside of context"))
+ // no-op when dims are inadequate
+ return 0
}
str := fmt.Sprintf(format, a...)