diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index b5f711352..b9e0ec1d0 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -77,7 +77,7 @@ pub fn merge(&mut self, mut other: Self) { } pub fn infobox(&self) -> Info { - let mut body: Vec<(&str, BTreeSet)> = Vec::with_capacity(self.len()); + let mut body: Vec<(BTreeSet, &str)> = Vec::with_capacity(self.len()); for (&key, trie) in self.iter() { let desc = match trie { KeyTrie::MappableCommand(cmd) => { @@ -89,14 +89,14 @@ pub fn infobox(&self) -> Info { KeyTrie::Node(n) => n.name(), KeyTrie::Sequence(_) => "[Multiple commands]", }; - match body.iter().position(|(d, _)| d == &desc) { + match body.iter().position(|(_, d)| d == &desc) { Some(pos) => { - body[pos].1.insert(key); + body[pos].0.insert(key); } - None => body.push((desc, BTreeSet::from([key]))), + None => body.push((BTreeSet::from([key]), desc)), } } - body.sort_unstable_by_key(|(_, keys)| { + body.sort_unstable_by_key(|(keys, _)| { self.order .iter() .position(|&k| k == *keys.iter().next().unwrap()) diff --git a/helix-view/src/info.rs b/helix-view/src/info.rs index 3080cf8e1..eced78e10 100644 --- a/helix-view/src/info.rs +++ b/helix-view/src/info.rs @@ -55,10 +55,10 @@ pub fn new(title: &str, body: &[(T, U)]) -> Self } } - pub fn from_keymap(title: &str, body: Vec<(&str, BTreeSet)>) -> Self { + pub fn from_keymap(title: &str, body: Vec<(BTreeSet, &str)>) -> Self { let body: Vec<_> = body .into_iter() - .map(|(desc, events)| { + .map(|(events, desc)| { let events = events.iter().map(ToString::to_string).collect::>(); (events.join(", "), desc) })