Properly process files that cannot be open for a reason (#37170)

Follow-up of https://github.com/zed-industries/zed/pull/36764

* Fix `anyhow!({e})` conversion lossing Collab error codes context when
opening a buffer remotely

* Use this context to only allow opening files that had not specific
Collab error code

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov
2025-08-29 14:14:27 +00:00
committed by GitHub
parent 20d32d111c
commit 5001c03711
4 changed files with 45 additions and 33 deletions
+23 -16
View File
@@ -648,23 +648,30 @@ impl ProjectItemRegistry {
) as Box<_>;
Ok((project_entry_id, build_workspace_item))
}
Err(e) => match entry_abs_path.as_deref().filter(|_| is_file) {
Some(abs_path) => match cx.update(|window, cx| {
T::for_broken_project_item(abs_path, is_local, &e, window, cx)
})? {
Some(broken_project_item_view) => {
let build_workspace_item = Box::new(
move |_: &mut Pane, _: &mut Window, cx: &mut Context<Pane>| {
cx.new(|_| broken_project_item_view).boxed_clone()
},
)
as Box<_>;
Ok((None, build_workspace_item))
Err(e) => {
if e.error_code() == ErrorCode::Internal {
if let Some(abs_path) =
entry_abs_path.as_deref().filter(|_| is_file)
{
if let Some(broken_project_item_view) =
cx.update(|window, cx| {
T::for_broken_project_item(
abs_path, is_local, &e, window, cx,
)
})?
{
let build_workspace_item = Box::new(
move |_: &mut Pane, _: &mut Window, cx: &mut Context<Pane>| {
cx.new(|_| broken_project_item_view).boxed_clone()
},
)
as Box<_>;
return Ok((None, build_workspace_item));
}
}
None => Err(e)?,
},
None => Err(e)?,
},
}
Err(e)
}
}
}))
});