Commit 651dd7c

Eric Bower  ·  2025-12-11 13:01:31 -0500 EST
parent a22dba5
fix(getTerminalSize): return default size if cols and rows are 0

The issue is that `getTerminalSize` can return 0x0 even when ioctl(TIOCGWINSZ) succeeds. The ghostty terminal library panics when initialized with zero dimensions.

The fix in `getTerminalSize` now validates that both rows and cols are positive before using them, otherwise falling back to the default 24x80.

Closes: https://github.com/neurosnap/zmx/issues/25
2 files changed,  +1, -3
M build.zig
+0, -2
1@@ -147,5 +147,3 @@ pub fn build(b: *std.Build) void {
2     upload_step.dependOn(&rsync_docs.step);
3     upload_step.dependOn(&rsync_dist.step);
4 }
5-
6-
M src/main.zig
+1, -1
1@@ -1020,7 +1020,7 @@ fn setupSigwinchHandler() void {
2 
3 fn getTerminalSize(fd: i32) ipc.Resize {
4     var ws: c.struct_winsize = undefined;
5-    if (c.ioctl(fd, c.TIOCGWINSZ, &ws) == 0) {
6+    if (c.ioctl(fd, c.TIOCGWINSZ, &ws) == 0 and ws.ws_row > 0 and ws.ws_col > 0) {
7         return .{ .rows = ws.ws_row, .cols = ws.ws_col };
8     }
9     return .{ .rows = 24, .cols = 80 };