Skip to content

Commit

Permalink
Replace an ASCII space check with a is_whitespace check in Atom::new
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrutar committed Dec 9, 2024
1 parent 387b17c commit 9c20c7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions matcher/src/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions matcher/src/pattern/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ fn case_matching() {
fn escape() {
let pat = Atom::parse("foo\\ bar", CaseMatching::Smart, Normalization::Smart);
assert_eq!(pat.needle.to_string(), "foo 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);
Expand Down

0 comments on commit 9c20c7a

Please sign in to comment.