@@ -612,8 +612,11 @@ fn _search(doc: &mut Document, view_id: ViewId, contents: &str, regex: &Regex) {
612 let text = doc.text();
612 let text = doc.text();
613 let start = doc.selection(view_id).cursor();
613 let start = doc.selection(view_id).cursor();
615− // TODO: use find_at to find the next match after the cursor, loop around the end
615+ // use find_at to find the next match after the cursor, loop around the end
617+ .find_at(contents, start)
618+ .or_else(|| regex.find(contents));
616− if let Some(mat) = regex.find_at(contents, start) {
619+ if let Some(mat) = mat {
617 let start = text.byte_to_char(mat.start());
620 let start = text.byte_to_char(mat.start());
618 let end = text.byte_to_char(mat.end());
621 let end = text.byte_to_char(mat.end());
619 let selection = Selection::single(start, end - 1);
622 let selection = Selection::single(start, end - 1);