1
0
Fork 0
mirror of synced 2024-05-02 03:24:25 +12:00

Ignore ascii non alphabetic characters in approximate search (#513)

This commit is contained in:
Rafał Mikrut 2021-12-21 09:13:35 +01:00 committed by GitHub
parent b320d6aa3a
commit fbb25c31b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -826,8 +826,14 @@ fn get_approximate_conversion(what: &mut String) {
}
ch => {
if tab_number == 0 {
space_before = false;
new_what.push(ch);
// Ignore all non alphabetic ascii characters like " or .
if !ch.is_ascii() || ch.is_ascii_alphabetic() {
space_before = false;
new_what.push(ch);
} else if !space_before {
new_what.push(' ');
space_before = true;
}
}
}
}
@ -852,5 +858,9 @@ mod tests {
let mut what = " HH) ".to_string();
get_approximate_conversion(&mut what);
assert_eq!(what, "HH");
let mut what = " fsf.f. ".to_string();
get_approximate_conversion(&mut what);
assert_eq!(what, "fsf f");
}
}