From 033d000489bffdc537bbb2f6bd0c888e54f084de Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 22 Apr 2022 10:24:12 +0200 Subject: [PATCH] Replace underscores with spaces when humanizing action names --- crates/command_palette/src/command_palette.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/command_palette/src/command_palette.rs b/crates/command_palette/src/command_palette.rs index b535450d12eb86903c4a381a2b70a814de04a565..5e3b3eb5dd6352fac4874c8ae135f17841e23b4b 100644 --- a/crates/command_palette/src/command_palette.rs +++ b/crates/command_palette/src/command_palette.rs @@ -269,6 +269,8 @@ fn humanize_action_name(name: &str) -> String { } else { result.push(':'); } + } else if char == '_' { + result.push(' '); } else if char.is_uppercase() { if !result.ends_with(' ') { result.push(' '); @@ -300,13 +302,17 @@ mod tests { #[test] fn test_humanize_action_name() { assert_eq!( - &humanize_action_name("editor::GoToDefinition"), + humanize_action_name("editor::GoToDefinition"), "editor: go to definition" ); assert_eq!( - &humanize_action_name("editor::Backspace"), + humanize_action_name("editor::Backspace"), "editor: backspace" ); + assert_eq!( + humanize_action_name("go_to_line::Deploy"), + "go to line: deploy" + ); } #[gpui::test]