fix: keybindings disappear when mixing presets with a wrong filter condition (#1568)

This commit is contained in:
三咲雅 · Misaki Masa 2024-08-29 12:43:03 +08:00 committed by GitHub
parent ddb8ce530f
commit b280d79f76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -67,10 +67,10 @@ impl<'de> Deserialize<'de> for Keymap {
fn mix(mut a: IndexSet<Chord>, b: IndexSet<Chord>, c: IndexSet<Chord>) -> Vec<Chord> { fn mix(mut a: IndexSet<Chord>, b: IndexSet<Chord>, c: IndexSet<Chord>) -> Vec<Chord> {
let mut seen = HashSet::new(); let mut seen = HashSet::new();
b.iter().filter_map(|v| v.on.get(1)).for_each(|&k| _ = seen.insert(k)); b.iter().filter(|&v| v.on.len() > 1).for_each(|v| _ = seen.insert(&v.on[..2]));
c.iter().filter_map(|v| v.on.get(1)).for_each(|&k| _ = seen.insert(k)); c.iter().filter(|&v| v.on.len() > 1).for_each(|v| _ = seen.insert(&v.on[..2]));
a.retain(|v| v.on.len() < 2 || !seen.contains(&v.on[1])); a.retain(|v| v.on.len() < 2 || !seen.contains(&v.on[..2]));
Preset::mix(a, b, c).collect() Preset::mix(a, b, c).collect()
} }