mirror of https://github.com/helix-editor/helix
search_next_impl: don't panic on invalid regex (#740)
parent
3ff5b001ac
commit
1d04e5938d
|
@ -1154,8 +1154,15 @@ fn search_next_impl(cx: &mut Context, extend: bool) {
|
||||||
if let Some(query) = registers.read('/') {
|
if let Some(query) = registers.read('/') {
|
||||||
let query = query.last().unwrap();
|
let query = query.last().unwrap();
|
||||||
let contents = doc.text().slice(..).to_string();
|
let contents = doc.text().slice(..).to_string();
|
||||||
let regex = Regex::new(query).unwrap();
|
if let Ok(regex) = Regex::new(query) {
|
||||||
search_impl(doc, view, &contents, ®ex, extend);
|
search_impl(doc, view, &contents, ®ex, extend);
|
||||||
|
} else {
|
||||||
|
// get around warning `mutable_borrow_reservation_conflict`
|
||||||
|
// which will be a hard error in the future
|
||||||
|
// see: https://github.com/rust-lang/rust/issues/59159
|
||||||
|
let query = query.clone();
|
||||||
|
cx.editor.set_error(format!("Invalid regex: {}", query));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue