Log project path that was no open due to no project entry found

This commit is contained in:
Kirill Bulatov 2023-12-04 12:45:57 +02:00
parent aa3c9b8568
commit 45230dcaf3
2 changed files with 6 additions and 4 deletions

View File

@ -1661,14 +1661,15 @@ impl Project {
path: impl Into<ProjectPath>,
cx: &mut ModelContext<Self>,
) -> Task<Result<(ProjectEntryId, AnyModelHandle)>> {
let task = self.open_buffer(path, cx);
let project_path = path.into();
let task = self.open_buffer(project_path.clone(), cx);
cx.spawn_weak(|_, cx| async move {
let buffer = task.await?;
let project_entry_id = buffer
.read_with(&cx, |buffer, cx| {
File::from_dyn(buffer.file()).and_then(|file| file.project_entry_id(cx))
})
.ok_or_else(|| anyhow!("no project entry"))?;
.with_context(|| format!("no project entry for {project_path:?}"))?;
let buffer: &AnyModelHandle = &buffer;
Ok((project_entry_id, buffer.clone()))

View File

@ -1691,14 +1691,15 @@ impl Project {
path: impl Into<ProjectPath>,
cx: &mut ModelContext<Self>,
) -> Task<Result<(ProjectEntryId, AnyModel)>> {
let task = self.open_buffer(path, cx);
let project_path = path.into();
let task = self.open_buffer(project_path.clone(), cx);
cx.spawn(move |_, mut cx| async move {
let buffer = task.await?;
let project_entry_id = buffer
.update(&mut cx, |buffer, cx| {
File::from_dyn(buffer.file()).and_then(|file| file.project_entry_id(cx))
})?
.ok_or_else(|| anyhow!("no project entry"))?;
.with_context(|| format!("no project entry for {project_path:?}"))?;
let buffer: &AnyModel = &buffer;
Ok((project_entry_id, buffer.clone()))