mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 02:37:21 +00:00
Add Project::open_buffer method
This commit is contained in:
parent
fe571f1d70
commit
0b1c27956b
1 changed files with 14 additions and 2 deletions
|
@ -2,13 +2,13 @@ pub mod fs;
|
|||
mod ignore;
|
||||
mod worktree;
|
||||
|
||||
use anyhow::Result;
|
||||
use anyhow::{anyhow, Result};
|
||||
use client::{Client, UserStore};
|
||||
use clock::ReplicaId;
|
||||
use futures::Future;
|
||||
use fuzzy::{PathMatch, PathMatchCandidate, PathMatchCandidateSet};
|
||||
use gpui::{AppContext, Entity, ModelContext, ModelHandle, Task};
|
||||
use language::{DiagnosticEntry, LanguageRegistry};
|
||||
use language::{Buffer, DiagnosticEntry, LanguageRegistry};
|
||||
use lsp::DiagnosticSeverity;
|
||||
use std::{
|
||||
path::Path,
|
||||
|
@ -113,6 +113,18 @@ impl Project {
|
|||
.cloned()
|
||||
}
|
||||
|
||||
pub fn open_buffer(
|
||||
&self,
|
||||
path: ProjectPath,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<ModelHandle<Buffer>>> {
|
||||
if let Some(worktree) = self.worktree_for_id(path.worktree_id) {
|
||||
worktree.update(cx, |worktree, cx| worktree.open_buffer(path.path, cx))
|
||||
} else {
|
||||
cx.spawn(|_, _| async move { Err(anyhow!("no such worktree")) })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_local_worktree(
|
||||
&mut self,
|
||||
abs_path: &Path,
|
||||
|
|
Loading…
Reference in a new issue