Allow opening buffers without a project entry
This commit is contained in:
parent
ae6ddceb67
commit
1f6c69c7dc
8 changed files with 228 additions and 90 deletions
|
@ -481,18 +481,21 @@ impl Pane {
|
|||
|
||||
pub(crate) fn open_item(
|
||||
&mut self,
|
||||
project_entry_id: ProjectEntryId,
|
||||
project_entry_id: Option<ProjectEntryId>,
|
||||
focus_item: bool,
|
||||
cx: &mut ViewContext<Self>,
|
||||
build_item: impl FnOnce(&mut ViewContext<Pane>) -> Box<dyn ItemHandle>,
|
||||
) -> Box<dyn ItemHandle> {
|
||||
let mut existing_item = None;
|
||||
for (index, item) in self.items.iter().enumerate() {
|
||||
if item.is_singleton(cx) && item.project_entry_ids(cx).as_slice() == [project_entry_id]
|
||||
{
|
||||
let item = item.boxed_clone();
|
||||
existing_item = Some((index, item));
|
||||
break;
|
||||
if let Some(project_entry_id) = project_entry_id {
|
||||
for (index, item) in self.items.iter().enumerate() {
|
||||
if item.is_singleton(cx)
|
||||
&& item.project_entry_ids(cx).as_slice() == [project_entry_id]
|
||||
{
|
||||
let item = item.boxed_clone();
|
||||
existing_item = Some((index, item));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1549,6 +1549,7 @@ impl Workspace {
|
|||
let abs_path = abs_path.clone();
|
||||
async move {
|
||||
let (worktree, project_path) = project_path?;
|
||||
// TODO kb consider excluded files here?
|
||||
if fs.is_file(&abs_path).await {
|
||||
Some(
|
||||
this.update(&mut cx, |this, cx| {
|
||||
|
@ -2129,13 +2130,13 @@ impl Workspace {
|
|||
})
|
||||
}
|
||||
|
||||
pub(crate) fn load_path(
|
||||
fn load_path(
|
||||
&mut self,
|
||||
path: ProjectPath,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Task<
|
||||
Result<(
|
||||
ProjectEntryId,
|
||||
Option<ProjectEntryId>,
|
||||
impl 'static + FnOnce(&mut ViewContext<Pane>) -> Box<dyn ItemHandle>,
|
||||
)>,
|
||||
> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue