diff --git a/matcher/src/pattern.rs b/matcher/src/pattern.rs index 0c554ba..d772ffb 100644 --- a/matcher/src/pattern.rs +++ b/matcher/src/pattern.rs @@ -171,8 +171,8 @@ impl Atom { let mut saw_backslash = false; for mut c in chars::graphemes(needle) { if saw_backslash { - if c == ' ' { - needle_.push(' '); + if c.is_whitespace() { + needle_.push(c); saw_backslash = false; continue; } else { @@ -196,7 +196,9 @@ impl Atom { } Normalization::Never => (), } - needle_.push(c); + if !saw_backslash { + needle_.push(c); + } } } else { let chars = chars::graphemes(needle).map(|mut c| { diff --git a/matcher/src/pattern/tests.rs b/matcher/src/pattern/tests.rs index 88880ba..c0575f2 100644 --- a/matcher/src/pattern/tests.rs +++ b/matcher/src/pattern/tests.rs @@ -87,6 +87,11 @@ fn case_matching() { fn escape() { let pat = Atom::parse("foo\\ bar", CaseMatching::Smart, Normalization::Smart); assert_eq!(pat.needle.to_string(), "foo bar"); + let pat = Atom::parse("foö\\ bar", CaseMatching::Smart, Normalization::Smart); + assert_eq!(pat.needle.to_string(), "foö bar"); + // escaped double-width IDEOGRAPHIC SPACE + let pat = Atom::parse("foo\\ bar", CaseMatching::Smart, Normalization::Smart); + assert_eq!(pat.needle.to_string(), "foo bar"); let pat = Atom::parse("\\!foo", CaseMatching::Smart, Normalization::Smart); assert_eq!(pat.needle.to_string(), "!foo"); assert_eq!(pat.kind, AtomKind::Fuzzy);