forge
Explore
Log in

Don't you dare go Hollow

The keys search matches whole keys, not substrings

Browse files at this commit

803b8e60a971aab0a156fbaf0dacbe8b32817295Ahmet Kaan GümüşParent: fbdd221
  • fix
    • the keys search matches whole keys, not substrings
Show full message
🐛 fix(app): the keys search matches whole keys, not substrings

Searching f1 dragged in Fullscreen's F11 because chords matched by
contains. Chords now match on whole keys (split on space and +), with
the full-chord substring kept for needles that spell a combination.
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 it228 // The heading above the row being looked at, until a row under it earns it