Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple commands now shown in view #5203

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,22 @@ impl KeyTrieNode {
}

pub fn infobox(&self) -> Info {
let mut body: Vec<(&str, BTreeSet<KeyEvent>)> = Vec::with_capacity(self.len());
let mut body: Vec<(String, BTreeSet<KeyEvent>)> = Vec::with_capacity(self.len());
let desc_separator = "; ";
for (&key, trie) in self.iter() {
let desc = match trie {
KeyTrie::Leaf(cmd) => {
if cmd.name() == "no_op" {
continue;
}
cmd.doc()
vec![cmd.doc().to_owned()]
}
KeyTrie::Node(n) => vec![n.name().to_owned()],
KeyTrie::Sequence(cmds) => {
cmds.iter().map(|x| x.doc().to_owned()).collect::<Vec<_>>()
}
KeyTrie::Node(n) => n.name(),
KeyTrie::Sequence(_) => "[Multiple commands]",
};
let desc = desc.join(desc_separator);
match body.iter().position(|(d, _)| d == &desc) {
Some(pos) => {
body[pos].1.insert(key);
Expand All @@ -107,7 +111,7 @@ impl KeyTrieNode {
if body.iter().all(|(desc, _)| desc.starts_with(&prefix)) {
body = body
.into_iter()
.map(|(desc, keys)| (desc.strip_prefix(&prefix).unwrap(), keys))
.map(|(desc, keys)| (desc.strip_prefix(&prefix).unwrap().to_owned(), keys))
.collect();
}
Info::from_keymap(self.name(), body)
Expand Down
2 changes: 1 addition & 1 deletion helix-view/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Info {
}
}

pub fn from_keymap(title: &str, body: Vec<(&str, BTreeSet<KeyEvent>)>) -> Self {
pub fn from_keymap(title: &str, body: Vec<(String, BTreeSet<KeyEvent>)>) -> Self {
let body: Vec<_> = body
.into_iter()
.map(|(desc, events)| {
Expand Down