diff options
author | gibbz00 | 2023-05-29 20:01:45 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2023-06-07 01:11:13 +0000 |
commit | 19326d23d15f5e7a1df61249d071e835a28905ed (patch) | |
tree | eacc028aaaef39b77aaa2e6d91788f3eaa55d230 /helix-term/src/keymap.rs | |
parent | 3a0892f793a0dbf1f99f5b7e6fb23cdff68fb519 (diff) |
Keymap infobox: Idiomatic body tuple.
Does not change any behavior other than making the tuple slightly
more idiomatic. Keymap infobox shows key events, then the respective
description. This commit makes sure that order is used from the get go,
rather than flipping it midway.
Diffstat (limited to 'helix-term/src/keymap.rs')
-rw-r--r-- | helix-term/src/keymap.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index b5f71135..b9e0ec1d 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -77,7 +77,7 @@ impl KeyTrieNode { } pub fn infobox(&self) -> Info { - let mut body: Vec<(&str, BTreeSet<KeyEvent>)> = Vec::with_capacity(self.len()); + let mut body: Vec<(BTreeSet<KeyEvent>, &str)> = Vec::with_capacity(self.len()); for (&key, trie) in self.iter() { let desc = match trie { KeyTrie::MappableCommand(cmd) => { @@ -89,14 +89,14 @@ impl KeyTrieNode { 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()) |