summaryrefslogtreecommitdiff
path: root/src/File.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/File.zig')
-rw-r--r--src/File.zig32
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| {