From 7c91cb45a4bdb2025c9210cc6aabb4a426c282dd Mon Sep 17 00:00:00 2001 From: Mohamed Mahmoud <152813205+Haroka-74@users.noreply.github.com> Date: Tue, 28 Apr 2026 12:47:52 +0300 Subject: [PATCH] fix: handle zero terminal cell height (#1184) ## What? Added a check for `cellHeight == 0` in the `imageRows` function within `view/html.go`. If the terminal height cannot be determined, it now defaults to a standard `16px` fallback. ## Why? When running in terminals that don't report cell size via `ioctl`, `getTerminalCellSize()` returns `0`. This previously caused a "division by zero" runtime panic during the row calculation for inline images: `(h + cellHeight - 1) / cellHeight`. Closes #865 --- view/html.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/view/html.go b/view/html.go index ba3846e6dbc1ddfbde393d8225967c56dd6c0405..f83b31dd86571c198aceea7a48c6cb725a783561 100644 --- a/view/html.go +++ b/view/html.go @@ -509,6 +509,9 @@ func imageRows(payload string) int { if data, err := base64.StdEncoding.DecodeString(payload); err == nil { if _, h, ok := clib.ImageDimensions(data); ok { cellHeight := getTerminalCellSize() + if cellHeight == 0 { + cellHeight = 16 + } rows = (h + cellHeight - 1) / cellHeight if rows < 1 { rows = 1