Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

which_key: Show task names for task::Spawn bindings (#64937)

Yvonnick FRIN1dc8844439af
diff --git a/crates/which_key/src/which_key.rs b/crates/which_key/src/which_key.rs
index eb28ec3fe6e..eff17ad7811 100644
--- a/crates/which_key/src/which_key.rs
+++ b/crates/which_key/src/which_key.rs
@@ -5,7 +5,9 @@ mod pending_keystrokes_indicator;
mod which_key_modal;
mod which_key_settings;
-use gpui::{App, KeybindingKeystroke, Keystroke, PlatformKeyboardMapper, SharedString, Window};
+use gpui::{
+ Action, App, KeybindingKeystroke, Keystroke, PlatformKeyboardMapper, SharedString, Window,
+};
pub use pending_keystrokes_indicator::PendingKeystrokesIndicator;
use settings::Settings;
use std::{sync::LazyLock, time::Duration};
@@ -77,7 +79,7 @@ fn collect_bindings_for_pending_input(
return None;
}
let remaining_keystrokes = remaining_keystrokes.to_vec();
- let action_name = command_palette::humanize_action_name(binding.action().name()).into();
+ let action_name = binding_label(binding.action());
Some(PendingBinding {
remaining_keystrokes,
action_name,
@@ -86,6 +88,13 @@ fn collect_bindings_for_pending_input(
.collect()
}
+fn binding_label(action: &dyn Action) -> SharedString {
+ match action.as_any().downcast_ref::<zed_actions::Spawn>() {
+ Some(zed_actions::Spawn::ByName { task_name, .. }) => task_name.clone().into(),
+ _ => command_palette::humanize_action_name(action.name()).into(),
+ }
+}
+
pub fn init(cx: &mut App) {
WhichKeySettings::register(cx);
@@ -244,4 +253,14 @@ mod tests {
expected_display_text
);
}
+
+ #[test]
+ fn test_binding_label_uses_task_name_for_spawn_by_name() {
+ let action = zed_actions::Spawn::ByName {
+ task_name: "lazygit".to_string(),
+ reveal_target: None,
+ };
+
+ assert_eq!(binding_label(&action), "lazygit");
+ }
}