diff options
Diffstat (limited to 'core/dump.zig')
| -rw-r--r-- | core/dump.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/core/dump.zig b/core/dump.zig index deb18dba..10d36350 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -143,6 +143,14 @@ pub fn dumpExit(p: *Pardes) !void { /// view showed in a dump made before the layer's lines were the buffer's /// (wire 31 and older: a view's bit, no lines), its lines in it (jj.loaded). fn afterLoad(p: *Pardes) void { + // Each view laid out again over its columns and its screen, as a resize + // lays it out: its geometry is derived, never read (View.replica). + const live = p.live; + for (p.views, 0..) |slot, k| if (slot != null) { + p.live = @intCast(k); + layout.compute(p); + }; + p.live = live; for (p.panes) |slot| if (slot) |pane| if (pane.file) |*f| { const text = pardes.panes.File.fileText(f, p.scratch.allocator()) catch continue; f.context.reload(p.tree_sitter_gpa, f.path, text, f.revision); @@ -1024,6 +1032,26 @@ test "a dump keeps the session's settings, and a restore applies them" { try std.testing.expect(!restored.settings.wrap); } +test "a view's geometry is laid out again at a load, never read: a pane's rect past its screen in a dump is the layout's after it" { + // The fuzz's restore road, seed 589: an image whose pane 0 said 534 + // rows on a 24-row screen, drawn: surface.zig's `at` asserted. + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + const want = p.view().rects[0]; + p.view().rects[0].h = 534; + p.view().col_w[0] = 900; + const dumped = try dumpBytes(p); + defer gpa.free(dumped); + p.view().rects[0] = want; + const q = try load(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }, dumped, null); + defer q.deinit(); + try std.testing.expectEqual(want, q.view().rects[0]); + try std.testing.expectEqual(@as(u16, 80), q.view().col_w[0]); + _ = q.frame_arena.reset(.retain_capacity); + _ = try q.render(q.frame_arena.allocator()); +} + test "a session with every column it may hold dumps and restores them all" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 1200, .rows = 24 }); |
