From 16d826a3f4c7bc6d58bd4fd99d61c7639e6e7ca2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sat, 24 Feb 2024 23:51:28 +0200 Subject: [PATCH] Show keybindings instead of the action names in the recent project modal --- crates/recent_projects/src/recent_projects.rs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index 314eccccacacfd7dea10d40992cba2923e64f739..5abb0d55d239e1ce02af3c0bdf8d83b3ab136bb4 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -146,11 +146,25 @@ impl EventEmitter for RecentProjectsDelegate {} impl PickerDelegate for RecentProjectsDelegate { type ListItem = ListItem; - fn placeholder_text(&self, _cx: &mut WindowContext) -> Arc { + fn placeholder_text(&self, cx: &mut WindowContext) -> Arc { + let action_binding_text = |action: &dyn gpui::Action| { + cx.bindings_for_action(action) + .into_iter() + .next() + .map(|binding| { + binding + .keystrokes() + .into_iter() + .map(ToString::to_string) + .collect::>() + .join(" ") + }) + .unwrap_or_else(|| format!("{action:?}")) + }; Arc::from(format!( - "`{:?}` reuses the window, `{:?}` opens in new", - menu::Confirm, - menu::SecondaryConfirm, + "{} reuses the window, {} opens a new one", + action_binding_text(&menu::Confirm), + action_binding_text(&menu::SecondaryConfirm), )) }