fix duplicate keymap
If one key is binding to multiple commands, only the last command will be executed
#[derive(PartialEq)]
enum KeymapMatch {
Full(String),
- Multiple(Vec<String>),
Prefix,
None,
}
@@ -204,8 +203,13 @@ pub fn key_down<T: KeyPressFocus>(
} else if matches.len() > 1
&& matches.iter().filter(|m| m.key != keypresses).count() == 0
{
- KeymapMatch::Multiple(
- matches.iter().map(|m| m.command.clone()).collect(),
+ KeymapMatch::Full(
+ matches
+ .iter()
+ .rev()
+ .next()
+ .map(|m| m.command.clone())
+ .unwrap(),
)
} else {
KeymapMatch::Prefix
@@ -217,14 +221,6 @@ pub fn key_down<T: KeyPressFocus>(
self.pending_keypress = Vec::new();
return true;
}
- KeymapMatch::Multiple(commands) => {
- let count = self.count.take();
- for command in commands {
- self.run_command(ctx, &command, count, focus, env);
- }
- self.pending_keypress = Vec::new();
- return true;
- }
KeymapMatch::Prefix => {
self.pending_keypress.push(keypress);
return false;
