From c223f717ae83b6c63eed22b42aa78239b85ce31d Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Thu, 30 Apr 2026 17:57:40 -0400 Subject: [PATCH] Fix row calculation: subtract 2 rows after floor division, not before floor((h - cellH) / cellH) != floor(h / cellH) - 1 when h/cellH is fractional. Use the simpler and correct floor(h / cellH) - 2 to reliably keep the bottom rows visible above the accessory bar. Co-authored-by: Orca --- mobile/src/terminal/TerminalWebView.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mobile/src/terminal/TerminalWebView.tsx b/mobile/src/terminal/TerminalWebView.tsx index c1fe73324..22a93bcc7 100644 --- a/mobile/src/terminal/TerminalWebView.tsx +++ b/mobile/src/terminal/TerminalWebView.tsx @@ -316,11 +316,12 @@ const XTERM_HTML = ` ? containerHeightPx : window.innerHeight; var cols = Math.floor(vpWidth / cellWidth); - // Why: subtract one cellHeight of padding before dividing, so the - // last row never clips against the container's bottom edge. Without - // this, Math.floor can produce a row count where the final row's - // bottom pixels sit right at or past the visible boundary. - var rows = Math.max(8, Math.floor((vpHeight - cellHeight) / cellHeight)); + // Why: subtract 2 rows after dividing. The WebView's reported height + // can slightly overstate the usable area (layout timing, subpixel + // rounding, safe-area insets). Subtracting 2 guarantees the last + // visible row plus the shell prompt (which often wraps on narrow + // screens) stays fully above the accessory bar. + var rows = Math.max(8, Math.floor(vpHeight / cellHeight) - 2); notify({ type: 'measure-result', cols: cols, rows: rows }); }