From 01528ae1e2f6d133566a612b1c0e72b363b56868 Mon Sep 17 00:00:00 2001 From: Connor Kuehl Date: Wed, 27 Apr 2022 19:46:03 -0500 Subject: grid: don't draw at a negative offset aerc panics when using macOS's default terminal emulator, Terminal.app, when closing all but aerc's tab: This error was also written to: /tmp/aerc-crash-20220427-194134.log panic: Attempted to create context with negative offset [recovered] panic: Attempted to create context with negative offset goroutine 1 [running]: git.sr.ht/~rjarry/aerc/logging.PanicHandler() /Users/ckuehl/src/aerc/logging/panic-logger.go:47 +0x58c panic({0x100d077a0, 0x14000032700}) /opt/homebrew/Cellar/go/1.18.1/libexec/src/runtime/panic.go:844 +0x258 git.sr.ht/~rjarry/aerc/lib/ui.(*Context).Subcontext(0x1400013e420?, 0x14000202360?, 0x140000ffc48?, 0x1009a10e4?, 0x100da9440?) /Users/ckuehl/src/aerc/lib/ui/context.go:47 +0x160 git.sr.ht/~rjarry/aerc/lib/ui.(*Grid).Draw(0x1400013e420, 0x14000202360) /Users/ckuehl/src/aerc/lib/ui/grid.go:143 +0x2bc git.sr.ht/~rjarry/aerc/widgets.(*Aerc).Draw(0x1400013e4d0, 0x14000202360) /Users/ckuehl/src/aerc/widgets/aerc.go:178 +0x30 git.sr.ht/~rjarry/aerc/lib/ui.(*UI).Tick(0x1400022bcc0) /Users/ckuehl/src/aerc/lib/ui/ui.go:116 +0x248 main.main() /Users/ckuehl/src/aerc/aerc.go:226 +0x9e8 I'm not entirely sure what the interactions are between the terminal emulator, aerc's grid, and the space that moves around when the tab bar disappears because there are no more tabs, but this fixes the issue 100% of the time and I haven't noticed any issues. Signed-off-by: Connor Kuehl Acked-by: Robin Jarry --- lib/ui/grid.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/ui/grid.go b/lib/ui/grid.go index f505ce0..2d19571 100644 --- a/lib/ui/grid.go +++ b/lib/ui/grid.go @@ -123,6 +123,10 @@ func (grid *Grid) Draw(ctx *Context) { cols := grid.columnLayout[cell.Column : cell.Column+cell.ColSpan] x := cols[0].Offset y := rows[0].Offset + if x < 0 || y < 0 { + continue + } + width := 0 height := 0 for _, col := range cols { -- cgit v1.2.3