diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 09:49:26 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 09:49:26 -0300 |
| commit | 1902703adec3e8461d623fe6e867bc8adb1e52e0 (patch) | |
| tree | 51927bbaef246a1b0d5d26084a8f6eb052fa375f /core | |
| parent | 58d7434f56a9fef3098cfc191fbd1cb32ec09cfb (diff) | |
| download | pardes-1902703adec3e8461d623fe6e867bc8adb1e52e0.tar.gz pardes-1902703adec3e8461d623fe6e867bc8adb1e52e0.zip | |
panes, views, dump: a band's rows are dumped and digested as the tag's rows are, so the layout a load's next step makes is the never-loaded session's (G4's soak, run 1: seed 1 rtt 30 client 3, `views[0].rects` alone at unit 0/1591, "digest 0 differs", once in 36 seed-runs); TEST FIRST: views.zig "a band its sync held short under a tag of two rows, dumped and loaded: its rows are the never-loaded session's, and so is the next layout" (40x18, a scratch pane under the file's, SPC Down: the band held to 6 of the 11 rows it wants under a tag of 2 rows, so the pane's tag rows 8; byteDump, load: on the base `expected 6, found 7`, and with that check left out the next step (a taller window) laid the host out 30 rows high where the session that never loaded laid it 33: `views[0].rects`); THE CAUSE: `band_rows` was derived (kept out of the dump and the digest) and a load made it again in views.bandsLoaded as `@min(Band.takes, tag_rows - 1)`, while Core.sync makes it `@min(Band.takes, r.h - the tag's own rows - Band.body_rows)`: where sync held the band short under a tag of two rows or more, the load's came back larger, and layout.floorRows, which reads the last sync's (`above = tag_rows - band_rows + Band.takes`: the tag's own rows as their difference), worked out a smaller floor for the band's pane: the next layout (every sync's first act, and every view unparked: views.unpark) borrowed fewer rows from its column than the session's did; the tag's own rows cannot be worked out again from its dumped rows once sync held the band short (they are then `r.h - body_rows`, whatever the tag's own); THE FIX: `band_rows` is in the dump and the digest, in the pane and in each view's share, as `tag_rows` is (only Core.sync writes it, a step), and views.bandsLoaded with its call in dump.afterLoad is deleted (P1's panic fix: the draw before a load's next step reads the dumped rows now; the draw's MAX_TAG_ROWS bounds stay); root.zig's kept_out loses its `band_rows` line; P1's test keeps its checks (the band's rows after the load equal, the draw, the bound), its name says "as dumped"; a dump of an older build has no `band_rows`: 0, which a build with no band had; a user's client could diverge (and be joined again) after a rollback or a join while a band was held short in a short column; core-test 1084/1255 (171 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core')
| -rw-r--r-- | core/dump.zig | 1 | ||||
| -rw-r--r-- | core/panes.zig | 5 | ||||
| -rw-r--r-- | core/root.zig | 1 | ||||
| -rw-r--r-- | core/views.zig | 53 |
4 files changed, 37 insertions, 23 deletions
diff --git a/core/dump.zig b/core/dump.zig index c0403c06..2dde9c8c 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -149,7 +149,6 @@ fn afterLoad(p: *Pardes) void { }; @import("jj.zig").loaded(p); pardes.TagState.loaded(p); - pardes.views.bandsLoaded(p); } /// A file kept slim in a dump (`dumpExit`, a closed pane's past its bound, diff --git a/core/panes.zig b/core/panes.zig index c984a73e..6fcb15b6 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -36,7 +36,7 @@ pub const Pane = struct { /// it (views.zig). (The 9P server's part of `fs` says so in its type.) pub const replica = .{ .local = .{ "pv", "pv_known" }, - .derived = .{ "band_rows", "ghost_at", "ghost_rows", "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "top_skip", "notices", "pan", "targets" }, + .derived = .{ "ghost_at", "ghost_rows", "wrap_line", "wrap_col", "wrap_pad", "wrap_n", "body_wrapped", "context_rows", "body_rows", "body_visible_rows", "context_row_limit", "geometry_key", "geometry_len", "top_skip", "notices", "pan", "targets" }, .len = .{ .{ "question", "question_len" }, .{ "shell_tail", "shell_tail_len" }, .{ "sel_snap", "nsel_snap" } }, // A picture's memory is its own allocator's (a dump loaded makes // it there). @@ -300,6 +300,9 @@ pub const Pane = struct { /// Pointer rows count from the tag's first, so a body starts at this one. /// Its last `band_rows` are the band unrolled under its text (Band.zig). tag_rows: u16 = 1, + /// Dumped as `tag_rows` is: what the next layout reads (floorRows takes + /// the tag's own rows as their difference) is the last sync's, which a + /// load cannot work out again where that sync held the band short. band_rows: u16 = 0, /// The tag's first line on screen. A tag with more lines than rows /// scrolls to keep its caret in view while it has the keyboard; pointer diff --git a/core/root.zig b/core/root.zig index 66e9e0e8..65fefb37 100644 --- a/core/root.zig +++ b/core/root.zig @@ -780,7 +780,6 @@ const kept_out = [_]struct { []const u8, []const u8, []const u8 }{ .{ "panes.zig", "ghost_at", "where a message's detail is drawn under the caret's line (Messages.detailUnder), made again from the step's state with the notices (Messages.collectNotices: at the top of update, presented, sync, place); a frame's are its own" }, .{ "panes.zig", "ghost_rows", "the detail's rows there, made again with ghost_at" }, .{ "panes.zig", "targets", "`]`'s and `[`'s tree targets as the body drawn last found them (body_layer.treeTargets), keyed by the text's revision, the caret, the lines shown and the way, so a frame asks again only when one moved; the draw's alone, no step reads it" }, - .{ "panes.zig views.zig", "band_rows", "the band's rows under a tag (Band.takes), made again from the view's tag state at every sync before anything reads them (layout.floorRows reads the last sync's, as it reads tag_rows)" }, .{ "panes.zig views.zig", "pan", "written by steps only (sync, a view unparked) from the pane and its terminal" }, .{ "File.zig", "cap line_starts line_cap widest", "the text's line index, of its bytes, and the widest line it found (an upper bound: which walk answers, never what)" }, .{ "File.zig", "highlights highlight_start syntax_dirty", "how a text looks, painted by frames: read by frames, and by a query's rows for colours only (out of their digest; what a step asks a worker to paint is never decided by them, Stream.paintRows)" }, diff --git a/core/views.zig b/core/views.zig index 7bf30aa0..02628e63 100644 --- a/core/views.zig +++ b/core/views.zig @@ -74,7 +74,7 @@ pub const PaneView = struct { /// In a dump (`Shares`): what a pane's step works out again. Its `view` /// is dumped: the step after `unpark` reads it before it syncs. - pub const replica = .{ .derived = .{ "notices", "pan", "band_rows" } }; + pub const replica = .{ .derived = .{ "notices", "pan" } }; }; /// The panes' shares of a view not live, as a session's dump keeps them @@ -171,24 +171,6 @@ pub fn undumped(p: *Pardes, others: []const Shares) void { } } -/// After a load: each view's band rows (derived: never dumped nor in the -/// digest) made again from its own tag state as its last sync made them. -/// Its tag rows, which are dumped, count them, and a view drawn before its -/// next step (drawOne: a replica client's, a pump's other views) reads the -/// tag's own rows as their difference (draw.zig): with the band's rows -/// zeroed by the load, a band's became the tag's, past MAX_TAG_ROWS. -pub fn bandsLoaded(p: *Pardes) void { - for (0..max) |k| if (isOpen(p, @intCast(k))) within(p, @intCast(k), {}, bandsOf) catch {}; -} - -fn bandsOf(_: void, p: *Pardes) anyerror!void { - for (p.panes, 0..) |slot, id| if (slot) |pane| { - const rows = if (pane.collapsed or pardes.Band.over(pane)) 0 else @min(pardes.Band.takes(p, id), pane.tag_rows -| 1); - pane.band_rows = rows; - pane.pv[p.live].band_rows = rows; - }; -} - /// The views a dump before `Pardes.views` kept (`OldDumped`): each its /// share of the session into `views[k]`, the rest as `undumped`. What /// each view holds is the session's then; one refused is freed. @@ -599,7 +581,7 @@ pub fn within(p: *Pardes, k: u8, ctx: anytype, comptime f: fn (@TypeOf(ctx), *Pa const testing = std.testing; const Key = pardes.Key; -test "a view not live with its band open, dumped and loaded, draws before its next step: its band's rows made again from its state, its tag's rows never past MAX_TAG_ROWS" { +test "a view not live with its band open, dumped and loaded, draws before its next step: its band's rows as dumped, its tag's rows never past MAX_TAG_ROWS" { const gpa = std.testing.allocator; const dump = @import("dump.zig"); const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 30 }); @@ -629,6 +611,37 @@ test "a view not live with its band open, dumped and loaded, draws before its ne _ = try drawOne(q, 0, .{ .ctx = null, .f = null }); } +test "a band its sync held short under a tag of two rows, dumped and loaded: its rows are the never-loaded session's, and so is the next layout" { + const gpa = std.testing.allocator; + const dump = @import("dump.zig"); + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 18 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + const host = p.view().active; + p.newScratchBelow(host); + const low = p.view().active; + p.view().active = host; + p.sync(); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = Key.down } }); + // The column has not the rows: the band is held under what it wants, + // under a tag of two rows of its own. + try testing.expect(pane.band_rows > 0 and pane.band_rows < pardes.Band.takes(p, host)); + try testing.expect(pane.tag_rows - pane.band_rows >= 2); + const bytes = try dump.byteDump(p); + defer gpa.free(bytes); + const q = try dump.load(gpa, .{ .tty_only = true, .cols = 40, .rows = 18 }, bytes, null); + defer q.deinit(); + try testing.expectEqual(pane.band_rows, q.panes[host].?.band_rows); + // The next step lays the column out from the band's floor (layout + // floorRows: the tag's own rows are its rows less the band's). + p.update(.{ .resize = .{ .cols = 40, .rows = 40 } }); + q.update(.{ .resize = .{ .cols = 40, .rows = 40 } }); + try testing.expectEqual(p.view().rects[host], q.view().rects[host]); + try testing.expectEqual(p.view().rects[low], q.view().rects[low]); + try testing.expectEqual(pardes.walk.digest(Pardes, p), pardes.walk.digest(Pardes, q)); +} + fn typeKeys(p: *Pardes, text: []const u8) void { for (text) |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); } |
