Skip to content

Commit 9c20c7a

Browse files
committed
Replace an ASCII space check with a is_whitespace check in Atom::new
1 parent 387b17c commit 9c20c7a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: matcher/src/pattern.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ impl Atom {
171171
let mut saw_backslash = false;
172172
for mut c in chars::graphemes(needle) {
173173
if saw_backslash {
174-
if c == ' ' {
175-
needle_.push(' ');
174+
if c.is_whitespace() {
175+
needle_.push(c);
176176
saw_backslash = false;
177177
continue;
178178
} else {

Diff for: matcher/src/pattern/tests.rs

+3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ fn case_matching() {
8787
fn escape() {
8888
let pat = Atom::parse("foo\\ bar", CaseMatching::Smart, Normalization::Smart);
8989
assert_eq!(pat.needle.to_string(), "foo bar");
90+
// escaped double-width IDEOGRAPHIC SPACE
91+
let pat = Atom::parse("foo\\  bar", CaseMatching::Smart, Normalization::Smart);
92+
assert_eq!(pat.needle.to_string(), "foo bar");
9093
let pat = Atom::parse("\\!foo", CaseMatching::Smart, Normalization::Smart);
9194
assert_eq!(pat.needle.to_string(), "!foo");
9295
assert_eq!(pat.kind, AtomKind::Fuzzy);

0 commit comments

Comments
 (0)