The keys search matches whole keys, not substrings
Browse files at this commit803b8e60a971aab0a156fbaf0dacbe8b32817295Parent: fbdd221- fix
- the keys search matches whole keys, not substrings
1 changed file +6 -1
- crates/app/src/menus.rs +6 -1
crates/app/src/menus.rsmodified+6 -1
| @@ -216,8 +216,13 @@ pub(crate) fn keys_filter(needle: &str, keymap: &Keymap) -> Vec<(usize, KeyRow)> | |||
| 216 | if needle.is_empty() { | 216 | if needle.is_empty() { |
| 217 | return rows.collect(); | 217 | return rows.collect(); |
| 218 | } | 218 | } |
| 219 | + // A chord matches on whole keys, not substrings -- "f1" must not drag in | ||
| 220 | + // "f11". A needle that spells a combination still matches the whole chord. | ||
| 219 | let hit = |label: &str, chord: &str| { | 221 | let hit = |label: &str, chord: &str| { |
| 220 | - label.to_lowercase().contains(&needle) || chord.to_lowercase().contains(&needle) | 222 | + let chord = chord.to_lowercase(); |
| 223 | + label.to_lowercase().contains(&needle) | ||
| 224 | + || chord.split([' ', '+']).any(|part| part == needle) | ||
| 225 | + || (needle.contains(['+', ' ']) && chord.contains(&needle)) | ||
| 221 | }; | 226 | }; |
| 222 | let mut out: Vec<(usize, KeyRow)> = Vec::new(); | 227 | let mut out: Vec<(usize, KeyRow)> = Vec::new(); |
| 223 | // The heading above the row being looked at, until a row under it earns it | 228 | // The heading above the row being looked at, until a row under it earns it |