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:
parent
a1d2e1106e
commit
1c5d9c221a
9 changed files with 199 additions and 43 deletions
|
@ -8,8 +8,8 @@ use editor::actions::{
|
|||
use editor::{Editor, EditorSettings};
|
||||
|
||||
use gpui::{
|
||||
Action, AnchorCorner, ClickEvent, ElementId, EventEmitter, InteractiveElement, ParentElement,
|
||||
Render, Styled, Subscription, View, ViewContext, WeakView,
|
||||
Action, AnchorCorner, ClickEvent, ElementId, EventEmitter, FocusHandle, FocusableView,
|
||||
InteractiveElement, ParentElement, Render, Styled, Subscription, View, ViewContext, WeakView,
|
||||
};
|
||||
use search::{buffer_search, BufferSearchBar};
|
||||
use settings::{Settings, SettingsStore};
|
||||
|
@ -110,12 +110,15 @@ impl Render for QuickActionBar {
|
|||
)
|
||||
};
|
||||
|
||||
let focus_handle = editor.read(cx).focus_handle(cx);
|
||||
|
||||
let search_button = editor.is_singleton(cx).then(|| {
|
||||
QuickActionBarButton::new(
|
||||
"toggle buffer search",
|
||||
IconName::MagnifyingGlass,
|
||||
!self.buffer_search_bar.read(cx).is_dismissed(),
|
||||
Box::new(buffer_search::Deploy::find()),
|
||||
focus_handle.clone(),
|
||||
"Buffer Search",
|
||||
{
|
||||
let buffer_search_bar = self.buffer_search_bar.clone();
|
||||
|
@ -133,6 +136,7 @@ impl Render for QuickActionBar {
|
|||
IconName::ZedAssistant,
|
||||
false,
|
||||
Box::new(InlineAssist::default()),
|
||||
focus_handle.clone(),
|
||||
"Inline Assist",
|
||||
{
|
||||
let workspace = self.workspace.clone();
|
||||
|
@ -321,6 +325,7 @@ struct QuickActionBarButton {
|
|||
icon: IconName,
|
||||
toggled: bool,
|
||||
action: Box<dyn Action>,
|
||||
focus_handle: FocusHandle,
|
||||
tooltip: SharedString,
|
||||
on_click: Box<dyn Fn(&ClickEvent, &mut WindowContext)>,
|
||||
}
|
||||
|
@ -331,6 +336,7 @@ impl QuickActionBarButton {
|
|||
icon: IconName,
|
||||
toggled: bool,
|
||||
action: Box<dyn Action>,
|
||||
focus_handle: FocusHandle,
|
||||
tooltip: impl Into<SharedString>,
|
||||
on_click: impl Fn(&ClickEvent, &mut WindowContext) + 'static,
|
||||
) -> Self {
|
||||
|
@ -339,6 +345,7 @@ impl QuickActionBarButton {
|
|||
icon,
|
||||
toggled,
|
||||
action,
|
||||
focus_handle,
|
||||
tooltip: tooltip.into(),
|
||||
on_click: Box::new(on_click),
|
||||
}
|
||||
|
@ -355,7 +362,9 @@ impl RenderOnce for QuickActionBarButton {
|
|||
.icon_size(IconSize::Small)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.selected(self.toggled)
|
||||
.tooltip(move |cx| Tooltip::for_action(tooltip.clone(), &*action, cx))
|
||||
.tooltip(move |cx| {
|
||||
Tooltip::for_action_in(tooltip.clone(), &*action, &self.focus_handle, cx)
|
||||
})
|
||||
.on_click(move |event, cx| (self.on_click)(event, cx))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue