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/hxcases/cases.jsonl | 121 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) (limited to 'test/hxcases/cases.jsonl') diff --git a/test/hxcases/cases.jsonl b/test/hxcases/cases.jsonl index 386013bf..b0a3aad4 100644 --- a/test/hxcases/cases.jsonl +++ b/test/hxcases/cases.jsonl @@ -358,3 +358,124 @@ {"name": "ins-arrows", "pane": "file", "text": "abc\ndef\n", "keys": "ix"} {"name": "ins-tab-col0", "pane": "file", "text": "ab\n", "keys": "i"} {"name": "ins-tab-mid", "pane": "file", "text": "ab\n", "keys": "li"} +{"name": "msel-C-basic", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "lC"} +{"name": "msel-C-basic-tty", "pane": "tty", "text": "aaa\nbbb\nccc\n", "keys": "lC"} +{"name": "msel-C-count", "pane": "file", "text": "aaa\nbbb\nccc\nddd\n", "keys": "2C"} +{"name": "msel-C-count-tty", "pane": "tty", "text": "aaa\nbbb\nccc\nddd\n", "keys": "2C"} +{"name": "msel-C-skips-short", "pane": "file", "text": "abcdef\nab\nabcdef\n", "keys": "4lC"} +{"name": "msel-C-stops-at-eof", "pane": "file", "text": "aa\nbb\n", "keys": "CCC"} +{"name": "msel-C-of-selection", "pane": "file", "text": "abcd\nabcd\nabcd\n", "keys": "vllC"} +{"name": "msel-C-above", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "jjl"} +{"name": "msel-C-above-tty", "pane": "tty", "text": "aaa\nbbb\nccc\n", "keys": "jjl"} +{"name": "msel-C-above-at-top", "pane": "file", "text": "aaa\nbbb\n", "keys": ""} +{"name": "msel-C-empty-line", "pane": "file", "text": "ab\n\ncd\n", "keys": "C"} +{"name": "msel-move-l", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "Cl"} +{"name": "msel-move-l-tty", "pane": "tty", "text": "aaa\nbbb\nccc\n", "keys": "Cl"} +{"name": "msel-move-jj", "pane": "file", "text": "aaaa\nbbbb\ncccc\ndddd\n", "keys": "2lCkk"} +{"name": "msel-word", "pane": "file", "text": "one two\nsix seven\n", "keys": "Cw"} +{"name": "msel-goto-line-end", "pane": "file", "text": "aaa\nbbbbb\n", "keys": "Cgl"} +{"name": "msel-keep-primary", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "CC,"} +{"name": "msel-keep-primary-tty", "pane": "tty", "text": "aaa\nbbb\nccc\n", "keys": "CC,"} +{"name": "msel-remove-primary", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "CC"} +{"name": "msel-remove-primary-last", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "CC)"} +{"name": "msel-rotate-fwd", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "CC)"} +{"name": "msel-rotate-fwd-tty", "pane": "tty", "text": "aaa\nbbb\nccc\n", "keys": "CC)"} +{"name": "msel-rotate-back", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "CC("} +{"name": "msel-rotate-wrap", "pane": "file", "text": "aaa\nbbb\n", "keys": "C))"} +{"name": "msel-split-newline", "pane": "file", "text": "aa\nbb\ncc\n", "keys": "%"} +{"name": "msel-split-partial", "pane": "file", "text": "abcd\nefgh\n", "keys": "vjl"} +{"name": "msel-split-partial-tty", "pane": "tty", "text": "abcd\nefgh\n", "keys": "vjl"} +{"name": "msel-merge", "pane": "file", "text": "aaa\nbbb\nccc\n", "keys": "CC"} +{"name": "msel-merge-consecutive", "pane": "file", "text": "aa\nbb\ncc\n", "keys": "xC"} +{"name": "msel-trim", "pane": "file", "text": " ab \n", "keys": "%_"} +{"name": "msel-trim-all-ws", "pane": "file", "text": " \n", "keys": "%_"} +{"name": "msel-trim-multi", "pane": "file", "text": " ab \n cd \n", "keys": "xC_"} +{"name": "msel-insert", "pane": "file", "text": "aa\nbb\n", "keys": "Cix"} +{"name": "msel-insert-tty", "pane": "tty", "text": "aa\nbb\n", "keys": "Cix"} +{"name": "msel-append", "pane": "file", "text": "aa\nbb\n", "keys": "Caz"} +{"name": "msel-insert-two-chars", "pane": "file", "text": "aa\nbb\ncc\n", "keys": "2Cixy"} +{"name": "msel-delete", "pane": "file", "text": "abc\nabc\n", "keys": "Cd"} +{"name": "msel-delete-tty", "pane": "tty", "text": "abc\nabc\n", "keys": "Cd"} +{"name": "msel-delete-selection", "pane": "file", "text": "abcd\nabcd\n", "keys": "vlCd"} +{"name": "msel-change", "pane": "file", "text": "abc\nabc\n", "keys": "Ccz"} +{"name": "msel-switch-case", "pane": "file", "text": "abc\nabc\n", "keys": "C~"} +{"name": "msel-switch-case-tty", "pane": "tty", "text": "abc\nabc\n", "keys": "C~"} +{"name": "msel-uppercase", "pane": "file", "text": "abc\nabc\n", "keys": "vlC"} +{"name": "msel-indent", "pane": "file", "text": "aa\nbb\n", "keys": "C"} +{"name": "msel-replace-char", "pane": "file", "text": "abc\nabc\n", "keys": "Crz"} +{"name": "msel-undo", "pane": "file", "text": "abc\nabc\n", "keys": "Cdu"} +{"name": "msel-open-below", "pane": "file", "text": "aa\nbb\n", "keys": "Coz"} +{"name": "msel-line-select", "pane": "file", "text": "aa\nbb\ncc\n", "keys": "Cx"} +{"name": "msel-collapse", "pane": "file", "text": "abcd\nabcd\n", "keys": "vllC;"} +{"name": "msel-flip", "pane": "file", "text": "abcd\nabcd\n", "keys": "vllC"} +{"name": "msel-yank-paste", "pane": "file", "text": "ab\ncd\n", "keys": "Cyp"} +{"name": "msel-esc-keeps", "pane": "file", "text": "aa\nbb\n", "keys": "C"} +{"name": "msel-select-mode", "pane": "file", "text": "abcd\nabcd\n", "keys": "Cvl"} +{"name": "msel-open-count", "pane": "file", "text": "ab\n", "keys": "2O"} +{"name": "msel-backspace", "pane": "file", "text": "abc\nabc\n", "keys": "Cla"} +{"name": "msel-backspace-tty", "pane": "tty", "text": "abc\nabc\n", "keys": "Cla"} +{"name": "sel-regex-basic", "pane": "file", "text": "alpha beta alpha\n", "keys": "%sa"} +{"name": "sel-regex-basic-tty", "pane": "tty", "text": "alpha beta alpha\n", "keys": "%sa"} +{"name": "sel-regex-word", "pane": "file", "text": "alpha beta alpha\n", "keys": "%salpha"} +{"name": "sel-regex-class", "pane": "file", "text": "a1b22c333\n", "keys": "%s[0-9]+"} +{"name": "sel-regex-class-tty", "pane": "tty", "text": "a1b22c333\n", "keys": "%s[0-9]+"} +{"name": "sel-regex-alt", "pane": "file", "text": "cat dog cat\n", "keys": "%scat|dog"} +{"name": "sel-regex-plus", "pane": "file", "text": "aa b aaa\n", "keys": "%sa+"} +{"name": "sel-regex-star-empty", "pane": "file", "text": "ab\n", "keys": "%sx*"} +{"name": "sel-regex-nomatch", "pane": "file", "text": "alpha beta\n", "keys": "%szzz"} +{"name": "sel-regex-esc", "pane": "file", "text": "alpha beta alpha\n", "keys": "%sa"} +{"name": "sel-regex-empty", "pane": "file", "text": "abc\n", "keys": "%s"} +{"name": "sel-regex-invalid", "pane": "file", "text": "abc\n", "keys": "%s["} +{"name": "sel-regex-within-sels", "pane": "file", "text": "aXa\nbXb\n", "keys": "xxsX"} +{"name": "sel-regex-within-sels-tty", "pane": "tty", "text": "aXa\nbXb\n", "keys": "xxsX"} +{"name": "sel-regex-at-cursors", "pane": "file", "text": "foo bar\nfoo baz\n", "keys": "xxsfoo"} +{"name": "sel-regex-narrow", "pane": "file", "text": "alpha beta alpha\n", "keys": "%salphasa"} +{"name": "sel-regex-select-mode", "pane": "file", "text": "alpha beta\n", "keys": "v5lsa"} +{"name": "sel-regex-multiline", "pane": "file", "text": "one\ntwo\nthree\n", "keys": "%so"} +{"name": "sel-regex-smart-case", "pane": "file", "text": "Alpha alpha ALPHA\n", "keys": "%salpha"} +{"name": "sel-regex-cased", "pane": "file", "text": "Alpha alpha ALPHA\n", "keys": "%sAlpha"} +{"name": "sel-regex-boundary", "pane": "file", "text": "cat cats\n", "keys": "%s\\bcat\\b"} +{"name": "sel-regex-whole", "pane": "file", "text": "abc\n", "keys": "%sabc"} +{"name": "sel-regex-then-motion", "pane": "file", "text": "foo bar foo baz\n", "keys": "%sfoow"} +{"name": "sel-regex-then-delete", "pane": "file", "text": "a1b2c3\n", "keys": "%s[0-9]d"} +{"name": "sel-regex-dot-newline", "pane": "file", "text": "ab\n", "keys": "%s."} +{"name": "sel-regex-caret", "pane": "file", "text": "ab\nab\n", "keys": "%s^a"} +{"name": "split-regex-comma", "pane": "file", "text": "a,b,c\n", "keys": "%S,"} +{"name": "split-regex-comma-tty", "pane": "tty", "text": "a,b,c\n", "keys": "%S,"} +{"name": "split-regex-lead", "pane": "file", "text": ",a,b\n", "keys": "%S,"} +{"name": "split-regex-trail", "pane": "file", "text": "a,b,\n", "keys": "%S,"} +{"name": "split-regex-adjacent", "pane": "file", "text": "a,,b\n", "keys": "%S,"} +{"name": "split-regex-ws", "pane": "file", "text": "one two three\n", "keys": "%S\\s+"} +{"name": "split-regex-ws-tty", "pane": "tty", "text": "one two three\n", "keys": "%S\\s+"} +{"name": "split-regex-nomatch", "pane": "file", "text": "abc\n", "keys": "%Sz"} +{"name": "split-regex-newline", "pane": "file", "text": "one\ntwo\nthree\n", "keys": "%S\\n"} +{"name": "split-regex-esc", "pane": "file", "text": "a,b,c\n", "keys": "%S,"} +{"name": "split-regex-within-sels", "pane": "file", "text": "aXa\nbXb\n", "keys": "xxSX"} +{"name": "split-regex-end", "pane": "file", "text": "abc\n", "keys": "%Sc"} +{"name": "comment-line", "pane": "file", "text": "alpha\nbeta\n", "keys": ""} +{"name": "comment-toggle-back", "pane": "file", "text": "alpha\nbeta\n", "keys": ""} +{"name": "comment-selection", "pane": "file", "text": "alpha\nbeta\ngamma\n", "keys": "xx"} +{"name": "comment-indent", "pane": "file", "text": " alpha\n beta\n", "keys": "%"} +{"name": "comment-indent-round-trip", "pane": "file", "text": " alpha\n beta\n", "keys": "%%"} +{"name": "comment-blank-skipped", "pane": "file", "text": "alpha\n\nbeta\n", "keys": "%"} +{"name": "comment-partial", "pane": "file", "text": "# alpha\nbeta\ngamma\n", "keys": "%"} +{"name": "comment-uncomment", "pane": "file", "text": "# alpha\n# beta\n", "keys": "%"} +{"name": "comment-margin0", "pane": "file", "text": "#alpha\n# beta\n", "keys": "%"} +{"name": "comment-token-only", "pane": "file", "text": "#\n#\n", "keys": "%"} +{"name": "comment-uncomment-deep", "pane": "file", "text": "# alpha\n # beta\n", "keys": "%"} +{"name": "comment-tab-indent", "pane": "file", "text": "\talpha\n\tbeta\n", "keys": "%"} +{"name": "comment-other-token", "pane": "file", "text": "// alpha\n// beta\n", "keys": "%"} +{"name": "comment-noeol", "pane": "file", "text": "alpha", "keys": ""} +{"name": "comment-empty", "pane": "file", "text": "\n", "keys": ""} +{"name": "comment-only-blank", "pane": "file", "text": " \n\t\n", "keys": "%"} +{"name": "comment-select-mode", "pane": "file", "text": "alpha\nbeta\n", "keys": "vj"} +{"name": "comment-count-ignored", "pane": "file", "text": "alpha\nbeta\ngamma\n", "keys": "3"} +{"name": "comment-undo", "pane": "file", "text": "alpha\nbeta\n", "keys": "%u"} +{"name": "comment-multi-cursor", "pane": "file", "text": "alpha\nbeta\ngamma\n", "keys": "C"} +{"name": "comment-same-line-cursors", "pane": "file", "text": "alpha beta\n", "keys": "wC"} +{"name": "comment-cursor-gap", "pane": "file", "text": "a\nb\nc\nd\n", "keys": "2C"} +{"name": "comment-split-cursors", "pane": "file", "text": "alpha\nbeta\ngamma\n", "keys": "%"} +{"name": "comment-last-line", "pane": "file", "text": "alpha\nbeta\n", "keys": "jj"} +{"name": "comment-then-insert", "pane": "file", "text": "alpha\n", "keys": "iz"} +{"name": "comment-after-sel-regex", "pane": "file", "text": "alpha\nbeta\ngamma\n", "keys": "%sa"} +{"name": "comment-after-split-regex", "pane": "file", "text": "a,b\nc,d\n", "keys": "%S,"} -- cgit v1.3