From bb0b5f8726ae50c7c8138ab0b14c8651b173ec2a Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Sun, 6 Aug 2023 13:32:32 +0200 Subject: [PATCH] fix negative matching --- src/pattern.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pattern.rs b/src/pattern.rs index cc37fd6..1efb7a9 100644 --- a/src/pattern.rs +++ b/src/pattern.rs @@ -116,8 +116,8 @@ impl PatternAtom { fn parse(raw: &str, normalize: bool, case: CaseMatching) -> PatternAtom { let mut atom = raw; - let inverse = atom.starts_with('!'); - if inverse { + let invert = atom.starts_with('!'); + if invert { atom = &atom[1..]; } @@ -150,11 +150,13 @@ impl PatternAtom { _ => (), } - if inverse && kind == PatternKind::Fuzzy { + if invert && kind == PatternKind::Fuzzy { kind = PatternKind::Substring } - PatternAtom::literal(atom, normalize, case, kind, true) + let mut pattern = PatternAtom::literal(atom, normalize, case, kind, true); + pattern.invert = invert; + pattern } }