diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 21:10:15 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 21:10:17 -0300 |
| commit | b28053aede910b8714db4f27ef66e59dd96945c0 (patch) | |
| tree | a0aea3ca051a21cf3378de5d587357e9208deebb /core/normal.zig | |
| parent | abe3817e8dd0af41e6b5786bdbeb631219b58c23 (diff) | |
| download | pardes-b28053aede910b8714db4f27ef66e59dd96945c0.tar.gz pardes-b28053aede910b8714db4f27ef66e59dd96945c0.zip | |
Prompt: `/` and `?` search a file's body as they are typed (walk UI, pick-ui SPEC.md §7.3, item 2 of line E): its places found from where it began (Places.search, the view's on the key, a frame's budget a tick after), tinted, the current one stronger and selected as soon as it is found (`?`: the last before the caret, once the text between is searched), the gutter marked in the blank after each line number (`▸` the current place's line, `▪` the others'), counted `3/7 · 5 lines` (`3/⋯` while they are found; the lines counted once, at the step they are all found, a pass to the last place), ` · wrapped` past the end from where it began, `0` for no match; a pattern that is no regex keeps the last places, dimmed (Places.paint), the reason in the count; Enter lands, the pattern in `/`, and folds the pane's one search word into its trail (`/dirty/ 3/7`, Trail.setWord: the newest back step, in place of the one it had); n and N write it again in place and echo `/dirty/ 4/7 · line 112` on the message row, ` ↻` after a step round an end, `–/7` with the selection off its places, every step (Prompt.settle beside the places'); the first Esc in normal mode clears a search's tints (SPEC §10.4's first step: C's Esc order when it lands) and the word stays, dimmed (draw.zig, Trail.spanOf); Look on the word lights its places again and selects the one it was on, Exec searches again from the caret (Trail.lookStep, execStep); `*` makes the selection's pattern the search word, no prompt and no query pane; Alt-Enter keeps the places as rows: today's query pane (Query.open .text), the body as it was; `?` is helix's backward search, a new role (modal.zig, config.zig); THE FAULTS THE TESTS MET, both B's and latent until a word step was made: Trail.wordOf returned the text of a COPY of the step (a slice of its stack frame: the word drawn as garbage), now the step's own bytes; Trail.lastCur held `cur` under `n`, though keep() leaves a held pane's at `n` (a search word alone: the dump's load moved it and the digests differed), now `n`; TEST FIRST: Prompt.zig "/ searches the body as it is typed ..." and "? searches back from the caret ..."; Places' `*` test reads the echo, Query's and Stream's `/` tests keep their query pane by Alt-Enter, Query's `*` test reads the word; test/perf.zig --search measures a key in `/` and `s` on a 1 MB file; goldens fsearch, lookrange (the prompt in the tag, the word in the trail); core-test 1016/1182 (166 skipped), shell-test 1229/1232, pane-test 182/184, behaviour-test 274/277 (the failures A's, as on item 1), process-test A's six and none of mine, term-test 17/17, kitty-test 45/45
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/normal.zig')
| -rw-r--r-- | core/normal.zig | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/core/normal.zig b/core/normal.zig index c59a847c..307f1296 100644 --- a/core/normal.zig +++ b/core/normal.zig @@ -1088,7 +1088,7 @@ fn shrinkSelToLineBounds(tab: u16, t: *Text, text: []const u8, range: modal.Sele pub fn textRole(role: modal.Normal.Role, tree: bool) bool { return switch (role) { .all_children, .all_siblings, .expand_node, .goto_class, .goto_comment, .goto_entry, .goto_function, .goto_parameter, .goto_test, .goto_xml_element, .next_sibling, .parent_node_end, .parent_node_start, .prev_sibling, .shrink_node => tree, - .append_output, .command_line, .format, .goto_callstack, .goto_change, .goto_declaration, .goto_definition, .goto_diagnostic, .goto_diagnostic_end, .goto_implementation, .goto_references, .goto_type_definition, .goto_view_bottom, .goto_view_top, .goto_word, .half_page_down, .half_page_up, .insert_output, .keep_pipe, .keep_regex, .leader, .macro_record, .macro_replay, .page_down, .page_up, .pipe_selection, .pipe_selection_to, .remove_regex, .repeat_insert, .search, .search_next, .search_prev, .select_regex, .split_regex, .view_bottom, .view_center, .view_middle, .view_scroll_down, .view_scroll_up, .view_top => false, + .append_output, .command_line, .format, .goto_callstack, .goto_change, .goto_declaration, .goto_definition, .goto_diagnostic, .goto_diagnostic_end, .goto_implementation, .goto_references, .goto_type_definition, .goto_view_bottom, .goto_view_top, .goto_word, .half_page_down, .half_page_up, .insert_output, .keep_pipe, .keep_regex, .leader, .macro_record, .macro_replay, .page_down, .page_up, .pipe_selection, .pipe_selection_to, .remove_regex, .repeat_insert, .search, .search_back, .search_next, .search_prev, .select_regex, .split_regex, .view_bottom, .view_center, .view_middle, .view_scroll_down, .view_scroll_up, .view_top => false, else => true, }; } @@ -1107,6 +1107,12 @@ pub fn textAction(e: Editor, t: *Text, a: modal.Normal.Action) edit.Error!void { if (comptime Editor.lib) return; // typed again by a macro, Esc is only helix's if (e.p.macro.replaying > 0) return; + // The first Esc clears a search's tints (pick-ui SPEC §7.3, + // §10.4's first step); its word stays in the trail, dimmed. + if (t.what == .body) if (t.pane()) |pane| if (pane.places.started and pane.places.provenance == .search) { + pane.places.clear(e.p.gpa); + return; + }; tagline.exitHeader(e.p); // out of a header too, as Shift-Esc return exec.runBuiltin(e.p, .Last, e.p.view().active, "", null); }, @@ -1253,14 +1259,13 @@ pub fn textAction(e: Editor, t: *Text, a: modal.Normal.Action) edit.Error!void { .decrement => return edit.normalAdjustNumber(e, t, -@as(i64, @intCast(a.count))), .search_selection, .search_selection_word => { try searchSelection(e, t, text, a.role == .search_selection_word); - // The pattern is line 1 of this text's query pane, made or - // reused, the keyboard staying here: n and N step its places. + // The pattern lights its places and is the pane's search word, + // no prompt asked (Prompt.zig): n and N step them. const pane = t.pane() orelse return; if (t.what == .body and pane.file != null and pane.query == null) { const name = if (e.register.* != 0) e.register.* else '/'; const pat = e.registers.value(name, 0) orelse return; - panes.Query.open(e.p, e.p.view().active, .text, pat, false); - pane.places.provenance = .search; + Prompt.star(e.p, pane, pat); } }, // prefix keys: what they begin is the command @@ -1385,10 +1390,11 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error! if (t.what == .body) return Prompt.open(p, pane, Prompt.ofBehavior(how)); return panes.startPrompt(p, pane, t, .{ .pipe = how }); }, - // `/` in a text is its query pane's line 1 (Query.zig); a - // terminal's still asks on the notice band. - .search => if (pane.file != null and t.what == .body) - panes.Query.open(p, v.active, .text, "", true) + // `/` and `?` in a file's text search it in its tag (Prompt.zig), + // Alt-Enter keeping the places as its query pane's rows (Query.zig); + // a terminal's still asks on the notice band. + .search, .search_back => if (pane.file != null and t.what == .body) + return Prompt.open(p, pane, if (a.role == .search) .search else .search_back) else return panes.startPrompt(p, pane, &pane.body, .{ .search = config.search_marker }), // In a file's text, n and N step its places while they answer for @@ -1397,9 +1403,12 @@ fn executeNormalAction(p: *Pardes, t: *Text, a: modal.Normal.Action) edit.Error! // places the rows hold, never the disk (a motion). .search_next, .search_prev => if (t.what == .body and pane.addon != null) return look.lookWalk(p, if (a.role == .search_next) 1 else -1, false) - else if (t.what == .body and pane.file != null and pane.places.answersN(p, pane)) - return pane.places.step(p, pane, a.role == .search_next, a.count, t.select) - else + else if (t.what == .body and pane.file != null and pane.places.answersN(p, pane)) { + // The pane's search word says where it went (Prompt.zig). + const was = pane.places.current; + pane.places.step(p, pane, a.role == .search_next, a.count, t.select); + return Prompt.stepped(p, v.active, a.role == .search_next, was); + } else return searchStep(p.editor(), t, text, a.role == .search_next, a.count), .goto_word => return startJump(p, pane, t), .macro_record => { |
