summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 00:08:11 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:16:28 -0300
commite5c10e836cbcc2f3409eb709683aba8a780d7ce7 (patch)
treec14a5152167f682853301f69c67ab8974d012ace
parent8d647e9c9fc747c14a222a53f9e3db1ba7a07d01 (diff)
downloadpardes-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
-rw-r--r--src/File.zig32
-rw-r--r--src/Stream.zig5
-rw-r--r--src/edit.zig2
-rw-r--r--src/ninep/ctl.zig5
4 files changed, 10 insertions, 34 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| {
diff --git a/src/Stream.zig b/src/Stream.zig
index a7a0bf53..8953e660 100644
--- a/src/Stream.zig
+++ b/src/Stream.zig
@@ -1464,10 +1464,9 @@ test "Stream: a Grep's rows recoloured are made again, never written, and a dump
// (the plain rows' kept word is theirs), and the rows are new ones.
_ = pardes.walk.digest(Pardes, p);
try testing.expect(f.location_rows.ptr != plain);
- // An edit drops them with the text they were for (dropped_marks): a
- // join's load of the session is it, digest for digest.
+ // An edit drops them: a join's load of the session is it, digest for
+ // digest.
panes.File.setContent(p, f, try p.gpa.dupe(u8, "value\n"));
- try testing.expect(f.dropped_marks != null);
const bytes = try pardes.dump.dumpBytes(p);
defer p.gpa.free(bytes);
const q = try pardes.dump.load(testing.allocator, p.opts, bytes, null);
diff --git a/src/edit.zig b/src/edit.zig
index 33b0f050..41859273 100644
--- a/src/edit.zig
+++ b/src/edit.zig
@@ -532,8 +532,6 @@ fn setEditTextSpan(p: *Pardes, t: *Text, new: []u8, known_end: ?modal.Cursor, sp
f.location_rows = &.{};
f.pager_spans = &.{};
panes.File.setContentSpan(p, f, kept, null);
- if (f.location_rows.len > 0) @import("locations.zig").freeRows(p.gpa, f.location_rows);
- p.gpa.free(f.pager_spans);
f.location_rows = rows;
f.pager_spans = spans;
return;
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index fd8f47d5..a584cc8f 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -2707,10 +2707,11 @@ test "what a /pager open writes after its directory is the text: plain in the bo
// An edit drops the colours (pager.zig's ponytail).
try testing.expectEqual(Status.ok, call(p, .{ .tag = 6, .op = .write, .node = Node.of(pn.serial, .body), .data = "more\n" }).reply.status);
try testing.expectEqual(@as(usize, 0), f.pager_spans.len);
- // Undone back to the paged text: its colours come back with it.
+ // Undone back to the paged text: the text comes back, its colours
+ // stay dropped (they were the program's, for the text it printed).
panes.File.undoStep(p, pn, true);
try testing.expectEqualStrings("red /a\nNext\n", f.content);
- try testing.expectEqual(@as(usize, 2), f.pager_spans.len);
+ try testing.expectEqual(@as(usize, 0), f.pager_spans.len);
// PagerColor off, and an open closed with no read: the same text, plain,
// in at the editor's next step (a close through a mount never waits).