summaryrefslogtreecommitdiff
path: root/src/edit.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-24 11:57:26 -0300
committerGabriel Schneider <[email protected]>2026-10-24 11:57:35 -0300
commit51903dd947f90381d1a908c488a019289a1c8413 (patch)
treeab5b2574642493c60476e6e9bcd7cc0e1c5e8d9e /src/edit.zig
parent18d89dcedaed1f8437799621675e88ca47d7cdc1 (diff)
downloadpardes-51903dd947f90381d1a908c488a019289a1c8413.tar.gz
pardes-51903dd947f90381d1a908c488a019289a1c8413.zip
Search converge 3/6: the query pane, line 1 the query and its first word the source, rows made live like Callstack's, the owner's places showing the set, a +Preview promoted in place, Enter freezes, Esc restores
Diffstat (limited to 'src/edit.zig')
-rw-r--r--src/edit.zig20
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