summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 19:06:05 -0300
committerGabriel Schneider <[email protected]>2026-11-21 22:09:35 -0300
commit32245dce9a1a09e4a95b16b0503e9ef6410dc5d2 (patch)
tree9f6881e3af9b63796e6c340439bb928b7454801d
parent78aa898cf2a55c5e4e78d968b37388e0cbc6e2d2 (diff)
downloadpardes-32245dce9a1a09e4a95b16b0503e9ef6410dc5d2.tar.gz
pardes-32245dce9a1a09e4a95b16b0503e9ef6410dc5d2.zip
terminals' views: a view is its row again after every reflow (terminal.zig `reflow`, which `resize` and `resizeDeferred` share: ghostty's pinned view set to column 0), so the row a replica's rollback puts a terminal's view back at (replica.zig `keepViews`/`putViews`, the view's row index, the one record of an emulator's view outside the copy) is the view that was there: ghostty pins a view to a CELL, a widening that joins a wrapped line's second row to its first left that cell mid-row, and the next narrowing carried it a row down, where a client put back by its row (at row 0 ghostty's `.top`) stayed: the same digest (the offset) until that reflow, then the client's view a row above the session's, the bytes soak's divergence (round 5: 5 whole runs of 29, every naming a 2-row pane at its history's top, `cat`'s long lines wrapped, panes resized all through); the previous change's two tests pass (term-test 19/19, the replica test under shell-test), a fuzz of put-back against left-alone emulators under random output, reflows and scrolls went from 5 apart in 191 seeds to 0 in 3,000; core-test 885/1046 (161 skipped), shell-test 1088/1091 (3 skipped), each the base's plus the new test (loads 5-11); the bytes soak, whole, untraced, --witness, on this tree frozen (its session doing nothing extra): 21 of 21 clean (against 5 of 29 before), seed 2 at 80 ms alone 16 of 16; the screen-state soak 5 of 6 (s9b-2: seed 1 at 207 ms, 'digest 11 differs in the session', the open screen-state fault scr-1, not this one); the frame and perf gate against tree3 PASS (77/77 frames, corpus2x +0.046%, 121 counts within 0.1%, client-key-down +0.0286%); daemon.py --far and --clients x3 on Debug and ReleaseSafe, plain 5 of 5 after one timing failure on each build at load 5-7, each passing again alone; nothing in replica.zig, tape.zig or wire.zig; a user sees a scrolled-back terminal keep the row its top line starts on through a widening and a narrowing (ghostty kept the joined cell's row: within a row of it); screen-state clients never reflow their own emulator and their terminal views are not digested: not this fault there
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
-rw-r--r--core/term/terminal.zig19
1 files changed, 15 insertions, 4 deletions
diff --git a/core/term/terminal.zig b/core/term/terminal.zig
index 535ca6dc..187ed144 100644
--- a/core/term/terminal.zig
+++ b/core/term/terminal.zig
@@ -631,19 +631,30 @@ pub fn resize(state: *State, cols: u16, rows: u16, later: bool) void {
state.resize_to = .{ .cols = cols, .rows = rows };
return;
}
- state.changes +%= 1;
- state.vt.resize(state.gpa, .{ .cols = cols, .rows = rows }) catch {};
+ reflow(state, cols, rows);
}
/// The size `resize` left for later, made; whether there was one.
pub fn resizeDeferred(state: *State) bool {
const size = state.resize_to orelse return false;
state.resize_to = null;
- state.changes +%= 1;
- state.vt.resize(state.gpa, .{ .cols = size.cols, .rows = size.rows }) catch {};
+ reflow(state, size.cols, size.rows);
return true;
}
+/// Its grid reflowed, and its view a row of its history again, as `viewTo`
+/// and `grid` have it: ghostty's view follows a cell, which a widening
+/// can leave mid-row (a wrapped line's second row joined to its first) and
+/// the next narrowing carries a row down, where a view put back at its row
+/// (a replica's rollback, core/replica.zig `putViews`) stays.
+fn reflow(state: *State, cols: u16, rows: u16) void {
+ state.changes +%= 1;
+ state.vt.resize(state.gpa, .{ .cols = cols, .rows = rows }) catch {};
+ inline for (.{ .primary, .alternate }) |which| if (state.vt.screens.get(which)) |screen| {
+ if (screen.pages.viewport == .pin) screen.pages.viewport_pin.x = 0;
+ };
+}
+
/// The emulator's size in pixels follows the core's cells: kitty graphics
/// placements are sized by it, and CSI 14/16 t report it.
pub fn cellPixels(state: *State, w: u32, h: u32) void {