Skip to content

Commit

Permalink
Use typable command doc when keybind provides no arguments
Browse files Browse the repository at this point in the history
This improves the display of the keymap popup for example, so that if
you bind a key like `C-x = ":buffer-close"` under the `<space>` menu,
the infobox shows "Close the current buffer." rather than `:buffer-close
[]`.
  • Loading branch information
the-mikedavis committed Feb 1, 2025
1 parent 8439ce5 commit e9c16b7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,17 @@ impl std::str::FromStr for MappableCommand {
.collect::<Vec<String>>();
typed::TYPABLE_COMMAND_MAP
.get(name)
.map(|cmd| MappableCommand::Typable {
name: cmd.name.to_owned(),
doc: format!(":{} {:?}", cmd.name, args),
args,
.map(|cmd| {
let doc = if args.is_empty() {
cmd.doc.to_string()
} else {
format!(":{} {:?}", cmd.name, args)
};
MappableCommand::Typable {
name: cmd.name.to_owned(),
doc,
args,
}
})
.ok_or_else(|| anyhow!("No TypableCommand named '{}'", s))
} else if let Some(suffix) = s.strip_prefix('@') {
Expand Down

0 comments on commit e9c16b7

Please sign in to comment.