From 211f3680649a697270161bdff8e5b3263aaa8d98 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Fri, 19 Apr 2024 21:25:11 -0400 Subject: [PATCH] Respect mode when starting a search (#10505) Currently the editor mode has no effect on the behavior of `search` and `rsearch`. We can pass in the right movement for the editor mode to make the behavior or `search` and `rsearch` match `search_next` and `search_prev` in select mode. --- helix-term/src/commands.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 0c26ad92e..cc7b84c4b 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -2080,6 +2080,11 @@ fn searcher(cx: &mut Context, direction: Direction) { let config = cx.editor.config(); let scrolloff = config.scrolloff; let wrap_around = config.search.wrap_around; + let movement = if cx.editor.mode() == Mode::Select { + Movement::Extend + } else { + Movement::Move + }; // TODO: could probably share with select_on_matches? let completions = search_completions(cx, Some(reg)); @@ -2104,7 +2109,7 @@ fn searcher(cx: &mut Context, direction: Direction) { search_impl( cx.editor, ®ex, - Movement::Move, + movement, direction, scrolloff, wrap_around,