Skip to content

Commit

Permalink
replace custom join with vec::join
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbz00 committed Feb 15, 2023
1 parent 91d8d92 commit 159150b
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,7 @@ impl ui::menu::Item for MappableCommand {
];
match command_list.get(name as &String) {
Some(key_events) => {
row[1] = Cell::from(format_key_events(key_events));
row[1] = Cell::from(key_events.join(", "));
}
None => {}
}
Expand All @@ -2619,25 +2619,13 @@ impl ui::menu::Item for MappableCommand {
let mut row: Vec<Cell> = vec![Cell::from(*name), Cell::from(""), Cell::from(*doc)];
match command_list.get(*name) {
Some(key_events) => {
row[1] = Cell::from(format_key_events(key_events));
row[1] = Cell::from(key_events.join(", "));
}
None => {}
}
return Row::new(row);
}
}

// TODO: Generalize into a Vec<String> Display implemention?
fn format_key_events(key_events: &Vec<String>) -> String {
let mut result_string: String = String::new();
for key_event in key_events {
if !result_string.is_empty() {
result_string.push_str(", ");
}
result_string.push_str(key_event);
}
result_string
}
}
}

Expand Down

0 comments on commit 159150b

Please sign in to comment.