From 7fb385cb7882f79bd448250b176f2d3a81de64f6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:55:26 -0300 Subject: terminal: resizeGrid takes the pane and the size, where it took an allocator too and threw it away (the emulator resizes with its state's own): the core's two calls (pardes.zig), the 9P pty's two and the kitty tests' two pass none Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/ninep/pty.zig | 4 ++-- src/pardes.zig | 4 ++-- src/terminal.zig | 5 ++--- test/kitty.zig | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index be5bb83f..b8356681 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -1008,10 +1008,10 @@ test "a run's answer says cut when its output's start is gone, and reads a bound // A resize between its start and end reflows the pins with the text. h = sh.send(p, node); sh.put(p, c ++ "one\r\ntwo\r\n"); - pardes.panes.terminal.resizeGrid(pane, gpa, 50, 20); + pardes.panes.terminal.resizeGrid(pane, 50, 20); sh.put(p, d ++ prompt); try testing.expectEqualStrings("exit 0\none\ntwo\n", sh.answered(p, node, h, into)); - pardes.panes.terminal.resizeGrid(pane, gpa, pane.cols, pane.rows); + pardes.panes.terminal.resizeGrid(pane, pane.cols, pane.rows); // A full-screen program leaves nothing on the primary screen, and a D // with no status is not a success. diff --git a/src/pardes.zig b/src/pardes.zig index fb26840b..2596e069 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -7319,7 +7319,7 @@ pub const Pardes = struct { // doc panes have no pty/emulator grid to reflow; just record // the size so bodyText renders the right number of rows if (pane.isTerminal()) { - panes.terminal.resizeGrid(pane, p.gpa, cols, rows); + panes.terminal.resizeGrid(pane, cols, rows); p.shell_rows.markStale(pane); // reflow moved every row p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = cols, .rows = rows } }); pane.fs.winsize = null; @@ -8731,7 +8731,7 @@ test "jump history terminal rectangle follows output and clears on reflow" { try std.testing.expectEqualStrings("alpha", try edit.selectionText(p, pane, pane.sel[0])); for (0..40) |_| p.update(.{ .output = .{ .pane = 0, .bytes = "more output\r\n" } }); try std.testing.expectEqualStrings("alpha", try edit.selectionText(p, pane, pane.sel[0])); - panes.terminal.resizeGrid(pane, p.gpa, pane.cols - 1, pane.rows); + panes.terminal.resizeGrid(pane, pane.cols - 1, pane.rows); try std.testing.expect(pane.pointerSelection(pane.sel[0]) == null); try std.testing.expectEqual(.none, pane.sel[0].state); } diff --git a/src/terminal.zig b/src/terminal.zig index acc7efdf..29a28e85 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -687,7 +687,7 @@ pub fn followOutput(pane: *Pane) void { /// Reflow the grid. A failed reflow keeps the grid it had rather than dropping /// a scrollback; the next resize retries with the same numbers. -pub fn resizeGrid(pane: *Pane, gpa: std.mem.Allocator, cols: u16, rows: u16) void { +pub fn resizeGrid(pane: *Pane, cols: u16, rows: u16) void { if (comptime !enabled) return; if (authorityOnly("resize a terminal")) return; const state = pane.terminal orelse return; @@ -705,7 +705,6 @@ pub fn resizeGrid(pane: *Pane, gpa: std.mem.Allocator, cols: u16, rows: u16) voi return; } state.changes +%= 1; - _ = gpa; state.vt.resize(state.gpa, .{ .cols = cols, .rows = rows }) catch {}; } @@ -1065,7 +1064,7 @@ test "document construction allocates only the pane and has inert terminal defau try std.testing.expect(!promptInputReady(pane)); scrollGrid(pane, 100); followOutput(pane); - resizeGrid(pane, allocator, 80, 24); + resizeGrid(pane, 80, 24); try std.testing.expectEqual(GridCursor{}, gridCursor(pane)); try std.testing.expectEqual(Scrollbar{}, scrollbar(pane)); try std.testing.expectEqualStrings("", try screenTextAlloc(pane, allocator)); diff --git a/test/kitty.zig b/test/kitty.zig index 737e8fbf..5531242e 100644 --- a/test/kitty.zig +++ b/test/kitty.zig @@ -580,7 +580,7 @@ test "kitty: an image follows its text when the shell scrolls, resizes and reflo try std.testing.expectEqual(o.y + 2, (try r.placesOf(10))[0].y); // A narrower pane reflows the text; the image stays on its row. const pane = r.pane(0); - terminal.resizeGrid(pane, gpa, 40, pane.rows); + terminal.resizeGrid(pane, 40, pane.rows); const text = try terminal.screenTextAlloc(pane, r.frame.allocator()); var row: usize = 0; var lines = std.mem.splitScalar(u8, text, '\n'); @@ -1106,7 +1106,7 @@ fn fuzzRun(seed: u64, steps: usize, trace: bool) !bool { r.p.update(.{ .resize = .{ .cols = cols, .rows = rows, .cell_pixels = .{ .w = 1 + rng.uintLessThan(u16, 30), .h = 1 + rng.uintLessThan(u16, 60) } } }); r.drain(); }, - 1 => terminal.resizeGrid(r.pane(0), gpa, 1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)), + 1 => terminal.resizeGrid(r.pane(0), 1 + rng.uintLessThan(u16, 120), 1 + rng.uintLessThan(u16, 40)), 2, 3 => { const drawn = try r.places(); if (trace) std.debug.print(" {d} places, {d} placements, {d} images\n", .{ drawn.len, r.placementCount(0), r.storage(0).images.count() }); -- cgit v1.3