fixed default leader key ('\') not expanding properly

This commit is contained in:
2026-03-03 03:33:53 -05:00
parent ad8d4db4ef
commit 7912f747fd
3 changed files with 10 additions and 1 deletions

View File

@@ -96,6 +96,7 @@ impl KeyMap {
expand_keymap(&self.action) expand_keymap(&self.action)
} }
pub fn compare(&self, other: &[KeyEvent]) -> KeyMapMatch { pub fn compare(&self, other: &[KeyEvent]) -> KeyMapMatch {
log::debug!("Comparing keymap keys {:?} with input {:?}", self.keys_expanded(), other);
let ours = self.keys_expanded(); let ours = self.keys_expanded();
if other == ours { if other == ours {
KeyMapMatch::IsExact KeyMapMatch::IsExact

View File

@@ -2145,6 +2145,7 @@ pub fn expand_aliases(
} }
pub fn expand_keymap(s: &str) -> Vec<KeyEvent> { pub fn expand_keymap(s: &str) -> Vec<KeyEvent> {
log::debug!("Expanding keymap for '{}'", s);
let mut keys = Vec::new(); let mut keys = Vec::new();
let mut chars = s.chars().collect::<VecDeque<char>>(); let mut chars = s.chars().collect::<VecDeque<char>>();
while let Some(ch) = chars.pop_front() { while let Some(ch) = chars.pop_front() {
@@ -2164,8 +2165,13 @@ pub fn expand_keymap(s: &str) -> Vec<KeyEvent> {
} }
} }
'>' => { '>' => {
log::debug!("Found key alias '{}'", alias);
if alias.eq_ignore_ascii_case("leader") { if alias.eq_ignore_ascii_case("leader") {
let leader = read_shopts(|o| o.prompt.leader.clone()); let mut leader = read_shopts(|o| o.prompt.leader.clone());
if leader == "\\" {
leader.push('\\');
}
log::debug!("Expanding leader key to '{}'", leader);
keys.extend(expand_keymap(&leader)); keys.extend(expand_keymap(&leader));
} else if let Some(key) = parse_key_alias(&alias) { } else if let Some(key) = parse_key_alias(&alias) {
keys.push(key); keys.push(key);
@@ -2182,6 +2188,7 @@ pub fn expand_keymap(s: &str) -> Vec<KeyEvent> {
} }
} }
log::debug!("Expanded keymap '{}' to {:?}", s, keys);
keys keys
} }

View File

@@ -418,6 +418,7 @@ impl ShedVi {
} else if matches.len() == 1 && matches[0].compare(&self.pending_keymap) == KeyMapMatch::IsExact { } else if matches.len() == 1 && matches[0].compare(&self.pending_keymap) == KeyMapMatch::IsExact {
// We have a single exact match. Execute it. // We have a single exact match. Execute it.
let keymap = matches[0].clone(); let keymap = matches[0].clone();
log::debug!("[keymap] self.pending_keymap={:?}", self.pending_keymap);
log::debug!("[keymap] exact match: {:?} -> {:?}", keymap.keys, keymap.action); log::debug!("[keymap] exact match: {:?} -> {:?}", keymap.keys, keymap.action);
self.pending_keymap.clear(); self.pending_keymap.clear();
let action = keymap.action_expanded(); let action = keymap.action_expanded();