Implement FileFinder
This commit is contained in:
parent
f4ccff7b72
commit
3a4c5aa440
3 changed files with 1615 additions and 1655 deletions
File diff suppressed because it is too large
Load diff
|
@ -146,6 +146,11 @@ impl<D: PickerDelegate> Picker<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn refresh(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
|
let query = self.editor.read(cx).text(cx);
|
||||||
|
self.update_matches(query, cx);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_matches(&mut self, query: String, cx: &mut ViewContext<Self>) {
|
pub fn update_matches(&mut self, query: String, cx: &mut ViewContext<Self>) {
|
||||||
let update = self.delegate.update_matches(query, cx);
|
let update = self.delegate.update_matches(query, cx);
|
||||||
self.matches_updated(cx);
|
self.matches_updated(cx);
|
||||||
|
|
|
@ -1961,50 +1961,50 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn open_abs_path(
|
pub fn open_abs_path(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// abs_path: PathBuf,
|
abs_path: PathBuf,
|
||||||
// visible: bool,
|
visible: bool,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
||||||
// cx.spawn(|workspace, mut cx| async move {
|
cx.spawn(|workspace, mut cx| async move {
|
||||||
// let open_paths_task_result = workspace
|
let open_paths_task_result = workspace
|
||||||
// .update(&mut cx, |workspace, cx| {
|
.update(&mut cx, |workspace, cx| {
|
||||||
// workspace.open_paths(vec![abs_path.clone()], visible, cx)
|
workspace.open_paths(vec![abs_path.clone()], visible, cx)
|
||||||
// })
|
})
|
||||||
// .with_context(|| format!("open abs path {abs_path:?} task spawn"))?
|
.with_context(|| format!("open abs path {abs_path:?} task spawn"))?
|
||||||
// .await;
|
.await;
|
||||||
// anyhow::ensure!(
|
anyhow::ensure!(
|
||||||
// open_paths_task_result.len() == 1,
|
open_paths_task_result.len() == 1,
|
||||||
// "open abs path {abs_path:?} task returned incorrect number of results"
|
"open abs path {abs_path:?} task returned incorrect number of results"
|
||||||
// );
|
);
|
||||||
// match open_paths_task_result
|
match open_paths_task_result
|
||||||
// .into_iter()
|
.into_iter()
|
||||||
// .next()
|
.next()
|
||||||
// .expect("ensured single task result")
|
.expect("ensured single task result")
|
||||||
// {
|
{
|
||||||
// Some(open_result) => {
|
Some(open_result) => {
|
||||||
// open_result.with_context(|| format!("open abs path {abs_path:?} task join"))
|
open_result.with_context(|| format!("open abs path {abs_path:?} task join"))
|
||||||
// }
|
}
|
||||||
// None => anyhow::bail!("open abs path {abs_path:?} task returned None"),
|
None => anyhow::bail!("open abs path {abs_path:?} task returned None"),
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
// pub fn split_abs_path(
|
pub fn split_abs_path(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// abs_path: PathBuf,
|
abs_path: PathBuf,
|
||||||
// visible: bool,
|
visible: bool,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
) -> Task<anyhow::Result<Box<dyn ItemHandle>>> {
|
||||||
// let project_path_task =
|
let project_path_task =
|
||||||
// Workspace::project_path_for_path(self.project.clone(), &abs_path, visible, cx);
|
Workspace::project_path_for_path(self.project.clone(), &abs_path, visible, cx);
|
||||||
// cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
// let (_, path) = project_path_task.await?;
|
let (_, path) = project_path_task.await?;
|
||||||
// this.update(&mut cx, |this, cx| this.split_path(path, cx))?
|
this.update(&mut cx, |this, cx| this.split_path(path, cx))?
|
||||||
// .await
|
.await
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn open_path(
|
pub fn open_path(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -2031,37 +2031,37 @@ impl Workspace {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn split_path(
|
pub fn split_path(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// path: impl Into<ProjectPath>,
|
path: impl Into<ProjectPath>,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Task<Result<Box<dyn ItemHandle>, anyhow::Error>> {
|
) -> Task<Result<Box<dyn ItemHandle>, anyhow::Error>> {
|
||||||
// let pane = self.last_active_center_pane.clone().unwrap_or_else(|| {
|
let pane = self.last_active_center_pane.clone().unwrap_or_else(|| {
|
||||||
// self.panes
|
self.panes
|
||||||
// .first()
|
.first()
|
||||||
// .expect("There must be an active pane")
|
.expect("There must be an active pane")
|
||||||
// .downgrade()
|
.downgrade()
|
||||||
// });
|
});
|
||||||
|
|
||||||
// if let Member::Pane(center_pane) = &self.center.root {
|
if let Member::Pane(center_pane) = &self.center.root {
|
||||||
// if center_pane.read(cx).items_len() == 0 {
|
if center_pane.read(cx).items_len() == 0 {
|
||||||
// return self.open_path(path, Some(pane), true, cx);
|
return self.open_path(path, Some(pane), true, cx);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// let task = self.load_path(path.into(), cx);
|
let task = self.load_path(path.into(), cx);
|
||||||
// cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
// let (project_entry_id, build_item) = task.await?;
|
let (project_entry_id, build_item) = task.await?;
|
||||||
// this.update(&mut cx, move |this, cx| -> Option<_> {
|
this.update(&mut cx, move |this, cx| -> Option<_> {
|
||||||
// let pane = pane.upgrade(cx)?;
|
let pane = pane.upgrade()?;
|
||||||
// let new_pane = this.split_pane(pane, SplitDirection::Right, cx);
|
let new_pane = this.split_pane(pane, SplitDirection::Right, cx);
|
||||||
// new_pane.update(cx, |new_pane, cx| {
|
new_pane.update(cx, |new_pane, cx| {
|
||||||
// Some(new_pane.open_item(project_entry_id, true, cx, build_item))
|
Some(new_pane.open_item(project_entry_id, true, cx, build_item))
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
// .map(|option| option.ok_or_else(|| anyhow!("pane was dropped")))?
|
.map(|option| option.ok_or_else(|| anyhow!("pane was dropped")))?
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub(crate) fn load_path(
|
pub(crate) fn load_path(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue