Skip to content

Commit

Permalink
refactor: add start-of-string anchor to regex patterns in lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
gvozdvmozgu authored and benfdking committed Nov 8, 2024
1 parent b5f93d7 commit 7da522c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/lib-core/src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&regex).unwrap()),
}
}

Expand Down

0 comments on commit 7da522c

Please sign in to comment.