diff options
Diffstat (limited to 'src/edit.zig')
| -rw-r--r-- | src/edit.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/edit.zig b/src/edit.zig index c9477c29..a06f5f2d 100644 --- a/src/edit.zig +++ b/src/edit.zig @@ -568,6 +568,26 @@ fn setEditTextSpan(p: *Pardes, t: *Text, new: []u8, known_end: ?modal.Cursor, sp return; } const pane = t.pane() orelse return retireEditText(p, new); + // A live query pane's rows are its line 1's (Query.zig): an edit there + // is refused, as a tag's prefix refuses one, and one from line 1 into + // them is cut at its end. The rows' metadata stays theirs across an + // edit of the line, which moves no row. + if (pane.file) |*f| if (pane.query) |q| if (!q.frozen) { + const kept = panes.Query.clampEdit(p, t, f.content, new) orelse return retireEditText(p, new); + if (kept.ptr != new.ptr) retireEditText(p, new); + const end = modal.positionAt(kept, kept.len - panes.File.spanOf(f.content, kept).tail); + t.last_edit = .{ .row = @intCast(end.row), .col = @intCast(end.col) }; + const rows = f.location_rows; + const spans = f.pager_spans; + 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; + }; // what changed ended where the texts agree again from their ends const old: []const u8, const row0: i32 = if (pane.file) |f| .{ f.content, 0 } else if (pane.ovl) |o| .{ o.text, o.row } else .{ "", 0 }; // ponytail: O(file), for the edits that do not say what they changed |
