Detailed changes
@@ -141,6 +141,15 @@
]
}
},
+ {
+ "context": "BufferSearchBar",
+ "bindings": {
+ "escape": "buffer_search::Dismiss",
+ "cmd-f": "buffer_search::FocusEditor",
+ "enter": "search::SelectNextMatch",
+ "shift-enter": "search::SelectPrevMatch"
+ }
+ },
{
"context": "Pane",
"bindings": {
@@ -152,15 +161,6 @@
"alt-cmd-r": "search::ToggleRegex"
}
},
- {
- "context": "BufferSearchBar",
- "bindings": {
- "escape": "buffer_search::Dismiss",
- "cmd-f": "buffer_search::FocusEditor",
- "enter": "search::SelectNextMatch",
- "shift-enter": "search::SelectPrevMatch"
- }
- },
// Bindings from VS Code
{
"context": "Editor",
@@ -303,6 +303,20 @@ impl BufferSearchBar {
direction: Direction,
cx: &mut RenderContext<Self>,
) -> ElementBox {
+ let action: Box<dyn Action>;
+ let tooltip;
+ match direction {
+ Direction::Prev => {
+ action = Box::new(SelectPrevMatch);
+ tooltip = "Select Previous Match";
+ }
+ Direction::Next => {
+ action = Box::new(SelectNextMatch);
+ tooltip = "Select Next Match";
+ }
+ };
+ let tooltip_style = cx.global::<Settings>().theme.tooltip.clone();
+
enum NavButton {}
MouseEventHandler::new::<NavButton, _, _>(direction as usize, cx, |state, cx| {
let style = &cx
@@ -316,11 +330,18 @@ impl BufferSearchBar {
.with_style(style.container)
.boxed()
})
- .on_click(move |_, _, cx| match direction {
- Direction::Prev => cx.dispatch_action(SelectPrevMatch),
- Direction::Next => cx.dispatch_action(SelectNextMatch),
+ .on_click({
+ let action = action.boxed_clone();
+ move |_, _, cx| cx.dispatch_any_action(action.boxed_clone())
})
.with_cursor_style(CursorStyle::PointingHand)
+ .with_tooltip::<NavButton, _>(
+ direction as usize,
+ tooltip.to_string(),
+ Some(action),
+ tooltip_style,
+ cx,
+ )
.boxed()
}
@@ -693,6 +693,20 @@ impl ProjectSearchBar {
direction: Direction,
cx: &mut RenderContext<Self>,
) -> ElementBox {
+ let action: Box<dyn Action>;
+ let tooltip;
+ match direction {
+ Direction::Prev => {
+ action = Box::new(SelectPrevMatch);
+ tooltip = "Select Previous Match";
+ }
+ Direction::Next => {
+ action = Box::new(SelectNextMatch);
+ tooltip = "Select Next Match";
+ }
+ };
+ let tooltip_style = cx.global::<Settings>().theme.tooltip.clone();
+
enum NavButton {}
MouseEventHandler::new::<NavButton, _, _>(direction as usize, cx, |state, cx| {
let style = &cx
@@ -706,11 +720,18 @@ impl ProjectSearchBar {
.with_style(style.container)
.boxed()
})
- .on_click(move |_, _, cx| match direction {
- Direction::Prev => cx.dispatch_action(SelectPrevMatch),
- Direction::Next => cx.dispatch_action(SelectNextMatch),
+ .on_click({
+ let action = action.boxed_clone();
+ move |_, _, cx| cx.dispatch_any_action(action.boxed_clone())
})
.with_cursor_style(CursorStyle::PointingHand)
+ .with_tooltip::<NavButton, _>(
+ direction as usize,
+ tooltip.to_string(),
+ Some(action),
+ tooltip_style,
+ cx,
+ )
.boxed()
}