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 <help@stably.ai>
This commit is contained in:
Jinwoo-H
2026-04-30 18:03:58 -04:00
co-authored by Orca
parent 7cc3ea9fff
commit c223f717ae
+6 -5
View File
@@ -316,11 +316,12 @@ const XTERM_HTML = `<!DOCTYPE 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 });
}