From f923d0342f7fbbc965867c19e03cb6c94fcb7fd3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 17 Nov 2026 06:08:57 -0300 Subject: hxlib: hxdiff's cases on the library, against helix's goldens and against the file pane (docs/next-editor.md, R6): test/hxlib.zig types each case into a `pardes-editor` value and prints its result as hxdiff prints a pane's, doing what an app does with the s, S, K and Alt-K it is handed back (the keys to its pattern, no answer) and printing a case that reaches any other action (a view, n and N, a macro, gw) as the caller's; hxdiff takes another driver's results (`--actual=`), and `zig build hxlib` (`-- --parity`) holds them to the goldens or the file pane; the key notation is test/hxkeys.zig, which both harnesses read; what the cases found, fixed: paneCursorLines gave the library's body no lines (mm, mi, ma, md, mr, insert-mode arrows), and the library's selectRegex keeps its pattern in `/` as pardes's prompt does (look.submitSearch); a page key in insert mode moves a view and is the caller's; test/lib's `zig build bench -- `: a key's cost, the pages it changes, a parse; hxlib 537 of 658 compared with 0 mismatches (5 waived as for pardes, 121 the caller's), --parity 617 of 738 with 0 mismatches and 0 waived; hxdiff 658 / parity 738 / hxgolf 124 with 0 mismatches, core-test 811 of 950, shell-test 990 of 993, replicas pass, lib-test pass --- src/lib_editor.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/lib_editor.zig') diff --git a/src/lib_editor.zig b/src/lib_editor.zig index 5430285a..86e494e1 100644 --- a/src/lib_editor.zig +++ b/src/lib_editor.zig @@ -356,6 +356,12 @@ pub fn Editor(comptime cap: Capacity) type { pub fn selectRegex(ed: *Self, a: std.mem.Allocator, pattern: []const u8, how: RegexMode) Outcome { const live = ed.thaw(a) catch return .{ .refused = .out_of_memory }; const t = &live.text; + // as pardes's prompt answers it (look.submitSearch): helix + // keeps the pattern in `/` + if (pattern.len > 0) { + live.registers.put(a, '/', pattern, 0, 1, true) catch return .{ .refused = .out_of_memory }; + live.registers.last_search = '/'; + } var snap: [max_selections]Selection = undefined; const got = t.ranges(t.own.?, 0, &snap); normal.selectByRegex(live.context(a), t, snap[0..got.n], got.pri, t.vsel.active and t.vsel.explicit, pattern, how); -- cgit v1.3