This commit is contained in:
a-kenji 2021-03-11 16:38:22 +01:00
parent 2b2b7325e7
commit b4fca93eb7

View File

@ -54,18 +54,17 @@ impl Keybinds {
/// Merges two Keybinds structs into one Keybinds struct /// Merges two Keybinds structs into one Keybinds struct
/// `other` overrides the ModeKeybinds of `self`. /// `other` overrides the ModeKeybinds of `self`.
fn merge_keybinds(&self, other: Keybinds) -> Keybinds { fn merge_keybinds(&self, other: Keybinds) -> Keybinds {
let mut keybinds = Keybinds::default(); let mut keybinds = Keybinds::new();
for mode in InputMode::iter() { for mode in self.0.keys().chain(other.0.keys()) {
let mut mode_keybinds: ModeKeybinds = if let Some(keybind) = self.0.get(&mode) { let mut mode_keybinds = ModeKeybinds::new();
keybind.clone() if let Some(keybind) = self.0.get(&mode) {
} else { mode_keybinds.0.extend(keybind.0.clone());
ModeKeybinds::default()
}; };
if let Some(keybind) = other.0.get(&mode) { if let Some(keybind) = other.0.get(&mode) {
mode_keybinds.0.extend(keybind.0.clone()); mode_keybinds.0.extend(keybind.0.clone());
} }
keybinds.0.insert(mode, mode_keybinds); keybinds.0.insert(mode.clone(), mode_keybinds);
} }
keybinds keybinds
} }