diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/screen_state.zig | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/screen_state.zig b/src/screen_state.zig index 27e20c0f..002c9da7 100644 --- a/src/screen_state.zig +++ b/src/screen_state.zig @@ -94,6 +94,11 @@ pub const Rows = struct { // older than the oldest row here. const was: ?u32 = if (p.garbage) null else if (pages.pointFromPin(.screen, p.*)) |pt| pt.screen.y else null; n.top += if (was) |w| y -| w else @as(u64, y) + t.rows; + // A reflow (a resize to fewer columns) puts more rows above the + // last top than ever scrolled past it: numbered from here, the + // history's oldest row is still row 0 or later. A resize + // renumbers anyway (`epoch`), so no peer holds the old numbers. + n.top = @max(n.top, y); p.* = top; } else { n.pin = try pages.trackPin(top); @@ -1369,6 +1374,31 @@ test "under a flood a delta is a screen of hashes: an unchanged row costs its ad try testing.expect(s.rep.holes.items.len > 0); } +test "a reflow to fewer columns keeps every history row numbered at or past 0" { + const gpa = testing.allocator; + const s = try Soak.init(gpa, testing.io, 80, 24, 1 << 20, 3); + defer s.deinit(); + s.resizes = false; + s.drops = false; + // Lines of 69 columns scrolled into the history, then the screen + // narrowed so that each wraps in three: more rows above the last top + // than ever scrolled past it (a window client's font, 2026-10-30: the + // session's peer started afresh at `top - history`, which overflowed). + var line: [80]u8 = undefined; + for (0..200) |i| { + s.stream.nextSlice(try std.fmt.bufPrint(&line, "{d:0>4} xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\n", .{i})); + s.changes += 1; + } + try s.send(0); + try s.land(); + try s.a.resize(gpa, .{ .cols = 30, .rows = 24 }); + s.changes += 1; + try s.send(0); + try s.land(); + try s.settle(); + try testing.expect(s.track.rows.top >= s.track.history); +} + test "several deltas in flight land in order, and a peer at the bound waits for an acknowledgement" { const gpa = testing.allocator; const s = try Soak.init(gpa, testing.io, 80, 24, 1 << 20, 2); |
