From 5bf8d6dd077517270377e5d8551108ecf252374f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 31 Jul 2026 05:04:26 -0300 Subject: multiple cursors, regex selection, and Ctrl-c comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The primary cursor stays exactly where it was — cur_row/cur_col plus vsel — and sels[] holds helix's OTHER ranges. That split is why nothing moved at one cursor: with nsel == 0 not one line of the existing motion, operator, render or mouse code takes a different branch, which is what protects 800 differential cases and 67 goldens. paneRanges/setPaneRanges are the whole list; setPaneRanges IS helix's Selection::new (min width 1, sorted, overlaps merged, primary follows its range through a merge). An ordinary key runs the single-selection handler once per range, visited last-first so an edit never disturbs a range still waiting, and each finished pass is remembered as a distance from the END of the text, which an earlier edit cannot move — helix's change mapping without a change map. pushUndo fires once per keystroke, yanks accumulate, and a builtin acts from the primary and stops the replay, which also closes the use-after-free window if it frees the pane. s and S reuse the / prompt wholesale rather than growing a second one: the pattern is typed into the tag tail, and every keystroke re-runs the match from the selection the prompt opened on, so the preview is live and Esc is just the empty pattern. mvzr does runtime patterns — a bytecode VM in a fixed-size struct with no allocator — with 64 ops and 8 char classes per pattern, no case-insensitive flag (helix's smart case is done by folding a scratch copy), no captures, no multi-line anchors. The last two are the two waivers. Ctrl-c is a whole-list key and not a per-cursor replay, because helix decides comment-vs-uncomment ONCE for the whole selection; replaying it would take that decision n times. Comment tokens are a table in config.zig keyed on the same extension syntax.zig picks grammars by. Found and fixed a pre-existing single-cursor bug on the way: la left the cursor one cell before where the append began. helix's restore_cursor can never walk past the origin; ours backed up unconditionally. hxdiff was green before AND after — the old one-selection contract could not see it. hxdiff 360 -> 481 cases, hxparity 440 -> 561, all goldens from real helix; the harness contract now reports every range and its primary, omitted when there is one, so 359 of the 360 old goldens are byte-identical. The one that moved is o-count: helix's 2o really does leave two cursors and could not say so before. --- test/snapshots/lspdebug.golden | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'test/snapshots/lspdebug.golden') diff --git a/test/snapshots/lspdebug.golden b/test/snapshots/lspdebug.golden index 2bce4aa6..bb0fee41 100644 --- a/test/snapshots/lspdebug.golden +++ b/test/snapshots/lspdebug.golden @@ -203,16 +203,16 @@ | 3 zig lib dir: /usr/lib/zig [OK] | 4 offsets: utf-8 walk caps: 512 files, 2000 rows | 5 -| 6 dependency imports gd can follow (6): +| 6 dependency imports gd can follow (7): | 7 zls /home/goblin/00-projects/0x4200.cafe | 8 tree-sitter /home/goblin/00-projects/0x4200.cafe | 9 zstbi /home/goblin/00-projects/0x4200.cafe -| 10 ghostty-vt /home/goblin/00-projects/0x4200.cafe -| 11 vaxis /home/goblin/00-projects/0x4200.cafe -| 12 uucode /home/goblin/00-projects/0x4200.cafe -| 13 asked from: /tmp/pardes-snap/lspdebug/cwd/z.zig -| 14 -| 15 answers: definition, declaration, type_definition, im +| 10 mvzr /home/goblin/00-projects/0x4200.cafe +| 11 ghostty-vt /home/goblin/00-projects/0x4200.cafe +| 12 vaxis /home/goblin/00-projects/0x4200.cafe +| 13 uucode /home/goblin/00-projects/0x4200.cafe +| 14 asked from: /tmp/pardes-snap/lspdebug/cwd/z.zig +| 15 | NOR /tmp/pardes-snap/lspdebug/cwd/+Lsp Del | 1 lsp explain — the definition query at byte 29 of z.zi | 2 -- cgit v1.3