From e988d4e24bfc0b80285754359b4b86f1b15b33f6 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 00:54:58 -0300 Subject: Restore keeps each pane's dot, as acme's dump does A restored text pane came back with its caret at its view's top, whatever had been selected. The dump now keeps each text pane's dot, q0 and q1 as acme's keeps a window's, and Restore puts it back without moving the view it kept. Two look-walk tests that restored and walked on now start from the match they were on. Co-Authored-By: Claude Opus 5.5 --- src/dump.zig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/dump.zig') diff --git a/src/dump.zig b/src/dump.zig index 5b0983ad..7101b708 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -142,6 +142,9 @@ pub const File = struct { origin_arg: []const u8 = "", mini_source: []const u8 = "", mini_colors_b64: []const u8 = "", + /// Its dot, q0 and q1 in bytes, as acme's dump keeps a window's; null + /// in older dumps. + dot: ?[2]u32 = null, }; pub const ImagePalette = enum { @@ -653,6 +656,10 @@ pub fn dumpState(p: *Pardes) !void { else try pardes.panes.Terminal.dumpPane(pane, arena, tag, body, scroll); dp.tag_tail = pane.tag.own; + if (dp.file) |*df| { + const dot = ctlfs.pane.dotOf(pane); + df.dot = .{ dot.q0, dot.q1 }; + } dp.serial = pane.serial; dump_panes[panes_len] = dp; panes_len += 1; @@ -918,3 +925,20 @@ test "a dump keeps the settings that differ from a fresh session's, and a restor try std.testing.expectEqual(config.Runtime.Placement.pardes, restored.settings.placement); try std.testing.expect(!restored.settings.verbose); } + +test "a restored pane keeps its dot, as acme's dump keeps a window's" { + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true }); + defer p.deinit(); + const pane = try p.setTestFile("one two three\nfour\n"); + ctlfs.pane.setDot(pane, .{ .q0 = 4, .q1 = 7 }); + try dumpState(p); + const restored = try initFromDump(gpa, .{ .tty_only = true }, p.dump_out.?); + defer restored.deinit(); + const again = for (restored.panes) |slot| { + if (slot) |candidate| if (candidate.file != null) break candidate; + } else return error.FileLost; + const dot = ctlfs.pane.dotOf(again); + try std.testing.expectEqual(@as(u32, 4), dot.q0); + try std.testing.expectEqual(@as(u32, 7), dot.q1); +} -- cgit v1.3