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
|
@ -1551,6 +1551,7 @@ impl Render for ProjectSearchBar {
|
|||
return div();
|
||||
};
|
||||
let search = search.read(cx);
|
||||
let focus_handle = search.focus_handle(cx);
|
||||
|
||||
let query_column = h_flex()
|
||||
.flex_1()
|
||||
|
@ -1571,18 +1572,21 @@ impl Render for ProjectSearchBar {
|
|||
h_flex()
|
||||
.child(SearchOptions::CASE_SENSITIVE.as_button(
|
||||
self.is_option_enabled(SearchOptions::CASE_SENSITIVE, cx),
|
||||
focus_handle.clone(),
|
||||
cx.listener(|this, _, cx| {
|
||||
this.toggle_search_option(SearchOptions::CASE_SENSITIVE, cx);
|
||||
}),
|
||||
))
|
||||
.child(SearchOptions::WHOLE_WORD.as_button(
|
||||
self.is_option_enabled(SearchOptions::WHOLE_WORD, cx),
|
||||
focus_handle.clone(),
|
||||
cx.listener(|this, _, cx| {
|
||||
this.toggle_search_option(SearchOptions::WHOLE_WORD, cx);
|
||||
}),
|
||||
))
|
||||
.child(SearchOptions::REGEX.as_button(
|
||||
self.is_option_enabled(SearchOptions::REGEX, cx),
|
||||
focus_handle.clone(),
|
||||
cx.listener(|this, _, cx| {
|
||||
this.toggle_search_option(SearchOptions::REGEX, cx);
|
||||
}),
|
||||
|
@ -1603,7 +1607,17 @@ impl Render for ProjectSearchBar {
|
|||
.map(|search| search.read(cx).filters_enabled)
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.tooltip(|cx| Tooltip::for_action("Toggle filters", &ToggleFilters, cx)),
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Toggle filters",
|
||||
&ToggleFilters,
|
||||
&focus_handle,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("project-search-toggle-replace", IconName::Replace)
|
||||
|
@ -1616,7 +1630,17 @@ impl Render for ProjectSearchBar {
|
|||
.map(|search| search.read(cx).replace_enabled)
|
||||
.unwrap_or_default(),
|
||||
)
|
||||
.tooltip(|cx| Tooltip::for_action("Toggle replace", &ToggleReplace, cx)),
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Toggle replace",
|
||||
&ToggleReplace,
|
||||
&focus_handle,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
|
@ -1650,8 +1674,16 @@ impl Render for ProjectSearchBar {
|
|||
})
|
||||
}
|
||||
}))
|
||||
.tooltip(|cx| {
|
||||
Tooltip::for_action("Go to previous match", &SelectPrevMatch, cx)
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Go to previous match",
|
||||
&SelectPrevMatch,
|
||||
&focus_handle,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
|
@ -1664,7 +1696,17 @@ impl Render for ProjectSearchBar {
|
|||
})
|
||||
}
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::for_action("Go to next match", &SelectNextMatch, cx)),
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Go to next match",
|
||||
&SelectNextMatch,
|
||||
&focus_handle,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
|
@ -1702,6 +1744,7 @@ impl Render for ProjectSearchBar {
|
|||
.border_color(cx.theme().colors().border)
|
||||
.rounded_lg()
|
||||
.child(self.render_text_input(&search.replacement_editor, cx));
|
||||
let focus_handle = search.replacement_editor.read(cx).focus_handle(cx);
|
||||
let replace_actions = h_flex().when(search.replace_enabled, |this| {
|
||||
this.child(
|
||||
IconButton::new("project-search-replace-next", IconName::ReplaceNext)
|
||||
|
@ -1712,7 +1755,17 @@ impl Render for ProjectSearchBar {
|
|||
})
|
||||
}
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::for_action("Replace next match", &ReplaceNext, cx)),
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Replace next match",
|
||||
&ReplaceNext,
|
||||
&focus_handle,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("project-search-replace-all", IconName::ReplaceAll)
|
||||
|
@ -1723,7 +1776,17 @@ impl Render for ProjectSearchBar {
|
|||
})
|
||||
}
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::for_action("Replace all matches", &ReplaceAll, cx)),
|
||||
.tooltip({
|
||||
let focus_handle = focus_handle.clone();
|
||||
move |cx| {
|
||||
Tooltip::for_action_in(
|
||||
"Replace all matches",
|
||||
&ReplaceAll,
|
||||
&focus_handle,
|
||||
cx,
|
||||
)
|
||||
}
|
||||
}),
|
||||
)
|
||||
});
|
||||
h_flex()
|
||||
|
@ -1790,6 +1853,7 @@ impl Render for ProjectSearchBar {
|
|||
search
|
||||
.search_options
|
||||
.contains(SearchOptions::INCLUDE_IGNORED),
|
||||
focus_handle.clone(),
|
||||
cx.listener(|this, _, cx| {
|
||||
this.toggle_search_option(SearchOptions::INCLUDE_IGNORED, cx);
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue