summaryrefslogtreecommitdiff
path: root/src/edit.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:38:06 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commitbdbab17204efdb785b6ab3cc2022484485c0ded2 (patch)
tree34aa73b7bfbccd46b008e06cd116f35130a117b3 /src/edit.zig
parente87e16547a17864b2a0cd574c1aa42d44125bc6c (diff)
downloadpardes-bdbab17204efdb785b6ab3cc2022484485c0ded2.tar.gz
pardes-bdbab17204efdb785b6ab3cc2022484485c0ded2.zip
g. goes to where the last edit ended
helix goto_last_modification: every range moves to the end of the last change (the start of a deletion, the end of an insertion), extending in select mode. The position is kept on the Text in surface rows, set where setEditText hands a body its new text, so a terminal's typed text has one too and moves with its scrollback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/edit.zig')
-rw-r--r--src/edit.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/edit.zig b/src/edit.zig
index 5e0d20a4..9398674a 100644
--- a/src/edit.zig
+++ b/src/edit.zig
@@ -484,6 +484,13 @@ pub fn setEditText(p: *Pardes, t: *Text, new: []u8) void {
return;
}
const pane = t.pane() orelse return retireEditText(p, new);
+ // 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 };
+ const front = std.mem.indexOfDiff(u8, old, new) orelse @min(old.len, new.len);
+ var back: usize = 0;
+ while (back < @min(old.len, new.len) - front and old[old.len - 1 - back] == new[new.len - 1 - back]) back += 1;
+ const end = modal.positionAt(new, new.len - back);
+ t.last_edit = .{ .row = @as(i32, @intCast(end.row)) + row0, .col = @intCast(end.col) };
if (pane.file) |*f| return panes.File.setContent(p, f, new);
panes.Terminal.setEditText(p, pane, new);
}