diff options
author | Blaž Hrastnik | 2021-04-08 06:58:20 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-04-08 13:34:06 +0000 |
commit | 9ca2909c80ff95b1dd4a1d92b7144d7bbfce3ca6 (patch) | |
tree | 098185e6b0150f180691e2f7d5df36c077bb50cd /helix-term/src | |
parent | 8b33ba2284f88bea4c6144364d75189255466661 (diff) |
Loop around the end on regex searches.
Diffstat (limited to 'helix-term/src')
-rw-r--r-- | helix-term/src/commands.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 2e205fa6..0cbc3f9d 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -612,8 +612,11 @@ fn _search(doc: &mut Document, view_id: ViewId, contents: &str, regex: &Regex) { let text = doc.text(); let start = doc.selection(view_id).cursor(); - // TODO: use find_at to find the next match after the cursor, loop around the end - if let Some(mat) = regex.find_at(contents, start) { + // use find_at to find the next match after the cursor, loop around the end + let mat = regex + .find_at(contents, start) + .or_else(|| regex.find(contents)); + if let Some(mat) = mat { let start = text.byte_to_char(mat.start()); let end = text.byte_to_char(mat.end()); let selection = Selection::single(start, end - 1); |