From 7da522c33843686850ebba31327d4623d21e9074 Mon Sep 17 00:00:00 2001 From: gvozdvmozgu Date: Fri, 8 Nov 2024 11:38:11 -0800 Subject: [PATCH] refactor: add start-of-string anchor to regex patterns in lexer --- crates/lib-core/src/parser/lexer.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/lib-core/src/parser/lexer.rs b/crates/lib-core/src/parser/lexer.rs index d21b0b273..284767fc5 100644 --- a/crates/lib-core/src/parser/lexer.rs +++ b/crates/lib-core/src/parser/lexer.rs @@ -255,10 +255,12 @@ impl Pattern { } pub fn regex(name: &'static str, regex: &'static str, syntax_kind: SyntaxKind) -> Self { + let regex = format!("^{regex}"); + Self { name, syntax_kind, - kind: SearchPatternKind::Regex(Regex::new(regex).unwrap()), + kind: SearchPatternKind::Regex(Regex::new(®ex).unwrap()), } }