diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 00:08:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 01:16:28 -0300 |
| commit | e5c10e836cbcc2f3409eb709683aba8a780d7ce7 (patch) | |
| tree | c14a5152167f682853301f69c67ab8974d012ace /src/File.zig | |
| parent | 8d647e9c9fc747c14a222a53f9e3db1ba7a07d01 (diff) | |
| download | pardes-e5c10e836cbcc2f3409eb709683aba8a780d7ce7.tar.gz pardes-e5c10e836cbcc2f3409eb709683aba8a780d7ce7.zip | |
File, edit: dropped marks go: an edit frees the location rows and pager colours it drops, and an undo back to the same text no longer brings them back (visible: a +Pager or a results buffer undone to its text is shown plain); the pager test in ninep/ctl says so and Stream's no longer asks for the field; File.State's walked shape changes (wire semantics)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/File.zig')
| -rw-r--r-- | src/File.zig | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/src/File.zig b/src/File.zig index 2e12fedf..8e976895 100644 --- a/src/File.zig +++ b/src/File.zig @@ -180,9 +180,6 @@ pub const State = struct { /// edit drops them (setContentSpan); shifting them through the splice, /// as pane.zig's shiftOne moves dot, would keep them. pager_spans: []pardes.pager.Span = &.{}, - /// The rows and spans an edit dropped, with the text they were for: an - /// edit (an undo) back to that very text takes them again. - dropped_marks: ?DroppedMarks = null, /// Seconds of the last content change, for the filesystem's stat; zero until edited. mtime: u32 = 0, /// Non-null for a generated output buffer rather than an on-disk file. @@ -816,7 +813,6 @@ pub fn deinit(p: *Pardes, pane: *Pane, file: *State) void { if (file.highlights.len > 0) p.tree_sitter_gpa.free(file.highlights); p.gpa.free(file.pager_spans); locations.freeRows(p.gpa, file.location_rows); - if (file.dropped_marks) |m| m.deinit(p.gpa); if (file.context_declarations.len > 0) p.tree_sitter_gpa.free(file.context_declarations); if (file.node_tree) |tree| syntax.freeTree(tree); for (file.node_history.items) |step| p.gpa.free(step.ranges); @@ -835,19 +831,6 @@ fn reportEdit(p: *Pardes, f: *State, new: []const u8) void { pardes.ctlfs.events.noteReplace(p, id, false, f.content, new); } -pub const DroppedMarks = struct { - pub const replica = .{ .blob = .{"rows"} }; - len: usize, - hash: u64, - rows: []locations.Row, - spans: []pardes.pager.Span, - - fn deinit(m: DroppedMarks, gpa: std.mem.Allocator) void { - locations.freeRows(gpa, m.rows); - gpa.free(m.spans); - } -}; - pub fn setContent(p: *Pardes, f: *State, new: []u8) void { setContentSpan(p, f, new, null); } @@ -873,16 +856,11 @@ pub fn setContentSpan(p: *Pardes, f: *State, new: []u8, span_in: ?Span) void { moved[i] = .{ .cursor = spliced(@min(at, f.content.len), f.content.len, new.len, span.?), .scroll = spliced(lineStart(p.gpa, tf, tf.scroll), f.content.len, new.len, span.?) }; } const old_starts = f.line_starts.ptr; - if (f.location_rows.len > 0 or f.pager_spans.len > 0) { - if (f.dropped_marks) |m| m.deinit(p.gpa); - f.dropped_marks = .{ .len = f.content.len, .hash = std.hash.Wyhash.hash(0, f.content), .rows = f.location_rows, .spans = f.pager_spans }; - f.location_rows = &.{}; - f.pager_spans = &.{}; - } else if (f.dropped_marks) |m| if (m.len == new.len and m.hash == std.hash.Wyhash.hash(0, new)) { - f.location_rows = m.rows; - f.pager_spans = m.spans; - f.dropped_marks = null; - }; + // An edit drops the rows and the colours, made for the text it changes. + locations.freeRows(p.gpa, f.location_rows); + f.location_rows = &.{}; + p.gpa.free(f.pager_spans); + f.pager_spans = &.{}; for (p.panes) |slot| if (slot) |pane| { if (pane.file) |*file| if (file == f) { for (0..pane.sel.len) |button| { |
