diff options
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 => { |
