Skip to content

Commit

Permalink
Fix bugs in search wraparound message (helix-editor#4101)
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Walrus authored and pathwave committed Nov 4, 2022
1 parent d61a1a5 commit 4bebcd6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ fn split_selection_on_newline(cx: &mut Context) {
doc.set_selection(view.id, selection);
}

#[allow(clippy::too_many_arguments)]
fn search_impl(
editor: &mut Editor,
contents: &str,
Expand All @@ -1572,6 +1573,7 @@ fn search_impl(
direction: Direction,
scrolloff: usize,
wrap_around: bool,
show_warnings: bool,
) {
let (view, doc) = current!(editor);
let text = doc.text().slice(..);
Expand Down Expand Up @@ -1612,9 +1614,13 @@ fn search_impl(
regex.find_iter(&contents[start..]).last()
}
};
editor.set_status("Wrapped around document");
} else {
editor.set_error("No more matches");
}
if show_warnings {
if wrap_around && mat.is_some() {
editor.set_status("Wrapped around document");
} else {
editor.set_error("No more matches");
}
}
}

Expand Down Expand Up @@ -1713,6 +1719,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
direction,
scrolloff,
wrap_around,
false,
);
},
);
Expand Down Expand Up @@ -1747,6 +1754,7 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir
direction,
scrolloff,
wrap_around,
true,
);
}
} else {
Expand Down

0 comments on commit 4bebcd6

Please sign in to comment.