Add cmd-g and cmd-shift-g to jump to next / previous result
I added the action handler on Pane so we can use these bindings when the find bar isn't focused.
This commit is contained in:
parent
f90193beea
commit
b1639e5677
2 changed files with 16 additions and 1 deletions
|
@ -17,7 +17,7 @@ use std::{
|
||||||
ops::Range,
|
ops::Range,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use workspace::{ItemViewHandle, Settings, Toolbar, Workspace};
|
use workspace::{ItemViewHandle, Pane, Settings, Toolbar, Workspace};
|
||||||
|
|
||||||
action!(Deploy, bool);
|
action!(Deploy, bool);
|
||||||
action!(Cancel);
|
action!(Cancel);
|
||||||
|
@ -46,12 +46,15 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
Binding::new("cmd-f", FocusEditor, Some("FindBar")),
|
Binding::new("cmd-f", FocusEditor, Some("FindBar")),
|
||||||
Binding::new("enter", GoToMatch(Direction::Next), Some("FindBar")),
|
Binding::new("enter", GoToMatch(Direction::Next), Some("FindBar")),
|
||||||
Binding::new("shift-enter", GoToMatch(Direction::Prev), Some("FindBar")),
|
Binding::new("shift-enter", GoToMatch(Direction::Prev), Some("FindBar")),
|
||||||
|
Binding::new("cmd-g", GoToMatch(Direction::Next), Some("Pane")),
|
||||||
|
Binding::new("cmd-shift-G", GoToMatch(Direction::Prev), Some("Pane")),
|
||||||
]);
|
]);
|
||||||
cx.add_action(FindBar::deploy);
|
cx.add_action(FindBar::deploy);
|
||||||
cx.add_action(FindBar::cancel);
|
cx.add_action(FindBar::cancel);
|
||||||
cx.add_action(FindBar::focus_editor);
|
cx.add_action(FindBar::focus_editor);
|
||||||
cx.add_action(FindBar::toggle_mode);
|
cx.add_action(FindBar::toggle_mode);
|
||||||
cx.add_action(FindBar::go_to_match);
|
cx.add_action(FindBar::go_to_match);
|
||||||
|
cx.add_action(FindBar::go_to_match_on_pane);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FindBar {
|
struct FindBar {
|
||||||
|
@ -386,6 +389,12 @@ impl FindBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn go_to_match_on_pane(pane: &mut Pane, action: &GoToMatch, cx: &mut ViewContext<Pane>) {
|
||||||
|
if let Some(find_bar) = pane.toolbar::<FindBar>() {
|
||||||
|
find_bar.update(cx, |find_bar, cx| find_bar.go_to_match(action, cx));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn on_query_editor_event(
|
fn on_query_editor_event(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: ViewHandle<Editor>,
|
_: ViewHandle<Editor>,
|
||||||
|
|
|
@ -417,6 +417,12 @@ impl Pane {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toolbar<T: Toolbar>(&self) -> Option<ViewHandle<T>> {
|
||||||
|
self.toolbars
|
||||||
|
.get(&TypeId::of::<T>())
|
||||||
|
.and_then(|toolbar| toolbar.to_any().downcast())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn active_toolbar(&self) -> Option<AnyViewHandle> {
|
pub fn active_toolbar(&self) -> Option<AnyViewHandle> {
|
||||||
let type_id = self.active_toolbar_type?;
|
let type_id = self.active_toolbar_type?;
|
||||||
let toolbar = self.toolbars.get(&type_id)?;
|
let toolbar = self.toolbars.get(&type_id)?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue