aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-16 09:58:43 +0000
committerBlaž Hrastnik2021-05-16 09:58:43 +0000
commit54de768915d6c4cde339261712a3188be20a62ff (patch)
tree9127d0344bcf53d2ccb3d0331222e5154daf0215
parent6e03019a2c7ec6e9d00a6308fe716468f767dd58 (diff)
Fix crash if typing | (regex or) into the prompt.
Zero-width matches at the start of the file make no sense to us.
-rw-r--r--helix-term/src/commands.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index c285fd41..5960121a 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -639,6 +639,11 @@ fn _search(doc: &mut Document, view: &mut View, contents: &str, regex: &Regex, e
let start = text.byte_to_char(mat.start());
let end = text.byte_to_char(mat.end());
+ if end == 0 {
+ // skip empty matches that don't make sense
+ return;
+ }
+
let head = end - 1;
let selection = if extend {