Add missing shortcuts in tooltips (#18282)

Fixes some missing shortcuts from Tooltips like the project search,
buffer search, quick action bar, ....


https://github.com/user-attachments/assets/d3a0160a-8d6e-4ddc-bf82-1fabeca42d59

This should hopefully help new users learn and discover some nice
keyboard shortcuts

Release Notes:

- Display keyboard shortcuts inside tooltips in the project search,
buffer search etc.
This commit is contained in:
Bennet Bo Fenner 2024-09-27 11:06:48 +02:00 committed by GitHub
parent a1d2e1106e
commit 1c5d9c221a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 199 additions and 43 deletions

View file

@ -166,7 +166,16 @@ impl TerminalPanel {
pub fn asssistant_enabled(&mut self, enabled: bool, cx: &mut ViewContext<Self>) {
self.assistant_enabled = enabled;
if enabled {
self.assistant_tab_bar_button = Some(cx.new_view(|_| InlineAssistTabBarButton).into());
let focus_handle = self
.pane
.read(cx)
.active_item()
.map(|item| item.focus_handle(cx))
.unwrap_or(self.focus_handle(cx));
self.assistant_tab_bar_button = Some(
cx.new_view(move |_| InlineAssistTabBarButton { focus_handle })
.into(),
);
} else {
self.assistant_tab_bar_button = None;
}
@ -859,16 +868,21 @@ impl Panel for TerminalPanel {
}
}
struct InlineAssistTabBarButton;
struct InlineAssistTabBarButton {
focus_handle: FocusHandle,
}
impl Render for InlineAssistTabBarButton {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let focus_handle = self.focus_handle.clone();
IconButton::new("terminal_inline_assistant", IconName::ZedAssistant)
.icon_size(IconSize::Small)
.on_click(cx.listener(|_, _, cx| {
cx.dispatch_action(InlineAssist::default().boxed_clone());
}))
.tooltip(move |cx| Tooltip::for_action("Inline Assist", &InlineAssist::default(), cx))
.tooltip(move |cx| {
Tooltip::for_action_in("Inline Assist", &InlineAssist::default(), &focus_handle, cx)
})
}
}