From 54de768915d6c4cde339261712a3188be20a62ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sun, 16 May 2021 18:58:43 +0900 Subject: [PATCH] Fix crash if typing | (regex or) into the prompt. Zero-width matches at the start of the file make no sense to us. --- helix-term/src/commands.rs | 5 +++++ 1 file changed, 5 insertions(+) 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 {