mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 05:15:00 +00:00
Cycle file finder entries on cmd-p
This commit is contained in:
parent
81a107f503
commit
541dd994a9
1 changed files with 67 additions and 51 deletions
|
@ -81,13 +81,27 @@ impl FoundPath {
|
||||||
actions!(file_finder, [Toggle]);
|
actions!(file_finder, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut AppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(toggle_file_finder);
|
cx.add_action(toggle_or_cycle_file_finder);
|
||||||
FileFinder::init(cx);
|
FileFinder::init(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
const MAX_RECENT_SELECTIONS: usize = 20;
|
const MAX_RECENT_SELECTIONS: usize = 20;
|
||||||
|
|
||||||
fn toggle_file_finder(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContext<Workspace>) {
|
fn toggle_or_cycle_file_finder(
|
||||||
|
workspace: &mut Workspace,
|
||||||
|
_: &Toggle,
|
||||||
|
cx: &mut ViewContext<Workspace>,
|
||||||
|
) {
|
||||||
|
match workspace.modal::<FileFinder>() {
|
||||||
|
Some(file_finder) => file_finder.update(cx, |file_finder, cx| {
|
||||||
|
let current_index = file_finder.delegate().selected_index();
|
||||||
|
file_finder.select_next(&menu::SelectNext, cx);
|
||||||
|
let new_index = file_finder.delegate().selected_index();
|
||||||
|
if current_index == new_index {
|
||||||
|
file_finder.select_first(&menu::SelectFirst, cx);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
None => {
|
||||||
workspace.toggle_modal(cx, |workspace, cx| {
|
workspace.toggle_modal(cx, |workspace, cx| {
|
||||||
let project = workspace.project().read(cx);
|
let project = workspace.project().read(cx);
|
||||||
|
|
||||||
|
@ -142,6 +156,8 @@ fn toggle_file_finder(workspace: &mut Workspace, _: &Toggle, cx: &mut ViewContex
|
||||||
finder
|
finder
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
Selected(ProjectPath),
|
Selected(ProjectPath),
|
||||||
|
|
Loading…
Reference in a new issue