Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in search wraparound message #4101

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,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 @@ -1569,6 +1570,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 @@ -1609,9 +1611,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 @@ -1706,6 +1712,7 @@ fn searcher(cx: &mut Context, direction: Direction) {
direction,
scrolloff,
wrap_around,
false,
);
},
);
Expand Down Expand Up @@ -1740,6 +1747,7 @@ fn search_next_or_prev_impl(cx: &mut Context, movement: Movement, direction: Dir
direction,
scrolloff,
wrap_around,
true,
);
}
} else {
Expand Down