Skip to content

Commit

Permalink
Respect mode when starting a search (helix-editor#10505)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis authored and Chirikumbrah committed Jun 15, 2024
1 parent 1bf7339 commit f483cd5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -2104,7 +2109,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
search_impl(
cx.editor,
&regex,
Movement::Move,
movement,
direction,
scrolloff,
wrap_around,
Expand Down

0 comments on commit f483cd5

Please sign in to comment.