summaryrefslogtreecommitdiff
path: root/src/edit.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:20:24 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit3992e9def8692710590deacbc20bd925e0f8d64a (patch)
treeab47f821d993903fedef10425eda547e26ae82b8 /src/edit.zig
parent06fe2290db7d0eb654b9a908358942cfde298e29 (diff)
downloadpardes-3992e9def8692710590deacbc20bd925e0f8d64a.tar.gz
pardes-3992e9def8692710590deacbc20bd925e0f8d64a.zip
Q records keys into a register and q types them again; . repeats the last insert
Macro.zig keeps keys to be typed again. Q records into @ (or "<reg>) in helix's key notation until the next Q; q replays a register's keys count times through the modal handling, where Esc does not hop panes and Enter, Tab and Space neither look, execute nor open the leader. . replays the normal command that entered the last insert session once and what was typed in it count times (helix repeat_last_insert). a at the end of the text now adds the newline helix's append_mode does, which a terminal's text does not. helix-golf's invert_dictionary passes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/edit.zig')
-rw-r--r--src/edit.zig15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/edit.zig b/src/edit.zig
index 3e12f169..a373741c 100644
--- a/src/edit.zig
+++ b/src/edit.zig
@@ -546,8 +546,19 @@ pub fn enterInsert(p: *Pardes, t: *Text, where: InsertAt, cnt: usize) void {
const hi_row = if (b) |bb| bb.hi_row else t.cur_row;
const hi_col = if (b) |bb| bb.hi_col else t.cur_col;
t.restore_cursor = true;
- const gap = modal.nextGrapheme(text, modal.offsetAt(text, .{ .row = @intCast(@max(0, hi_row)), .col = @intCast(@max(0, hi_col)) }));
- const gc = modal.positionAt(text, gap);
+ const hi = modal.offsetAt(text, .{ .row = @intCast(@max(0, hi_row)), .col = @intCast(@max(0, hi_col)) });
+ const gap = modal.nextGrapheme(text, hi);
+ // helix append_mode: a range that reaches the end of the text
+ // gets a newline after it to append before (a terminal's text
+ // is not the editor's to grow)
+ const terminal = t.what == .body and if (t.pane()) |pane| pane.isTerminal() else false;
+ var now = text;
+ if (hi < text.len and gap >= text.len and !terminal) {
+ const grown = std.mem.concat(p.gpa, u8, &.{ text, "\n" }) catch return;
+ setEditText(p, t, grown);
+ now = grown; // what setEditText keeps; `text` may be gone
+ }
+ const gc = modal.positionAt(now, gap);
t.cur_row = @intCast(gc.row);
t.cur_col = @intCast(gc.col);
// helix append_mode: the range reaches one past its end, which