Skip to content

Commit

Permalink
Use key-sequence format for command palette keybinds (helix-editor#4712)
Browse files Browse the repository at this point in the history
The text within the command palette used a custom format to display
the keybinding for a command. This change switches to the key sequence
format that we use for pending keys and macros.
  • Loading branch information
the-mikedavis authored and Shekhinah Memmel committed Dec 11, 2022
1 parent 818c872 commit c6aab7d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use crate::{

use crate::job::{self, Jobs};
use futures_util::StreamExt;
use std::{collections::HashMap, fmt, fmt::Write, future::Future};
use std::{collections::HashMap, fmt, future::Future};
use std::{collections::HashSet, num::NonZeroUsize};

use std::{
Expand Down Expand Up @@ -2487,13 +2487,11 @@ impl ui::menu::Item for MappableCommand {
let fmt_binding = |bindings: &Vec<Vec<KeyEvent>>| -> String {
bindings.iter().fold(String::new(), |mut acc, bind| {
if !acc.is_empty() {
acc.push_str(", ");
acc.push(' ');
}
for key in bind {
acc.push_str(&key.key_sequence_format());
}
bind.iter().fold(false, |needs_plus, key| {
write!(&mut acc, "{}{}", if needs_plus { "+" } else { "" }, key)
.expect("Writing to a string can only fail on an Out-Of-Memory error");
true
});
acc
})
};
Expand Down

0 comments on commit c6aab7d

Please sign in to comment.