Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Properly process files that cannot be open for a reason (#37170)
Kirill Bulatov5001c0371163
diff --git a/crates/client/src/client.rs b/crates/client/src/client.rsindex bdbf049b75e..1e735b0025f 100644--- a/crates/client/src/client.rs+++ b/crates/client/src/client.rs@@ -1696,21 +1696,10 @@ impl Client {);cx.spawn(async move |_| match future.await {Ok(()) => {- log::debug!(- "rpc message handled. client_id:{}, sender_id:{:?}, type:{}",- client_id,- original_sender_id,- type_name- );+ log::debug!("rpc message handled. client_id:{client_id}, sender_id:{original_sender_id:?}, type:{type_name}");}Err(error) => {- log::error!(- "error handling message. client_id:{}, sender_id:{:?}, type:{}, error:{:?}",- client_id,- original_sender_id,- type_name,- error- );+ log::error!("error handling message. client_id:{client_id}, sender_id:{original_sender_id:?}, type:{type_name}, error:{error:#}");}}).detach();diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rsindex 295bad6e596..89bd4b27c9c 100644--- a/crates/project/src/buffer_store.rs+++ b/crates/project/src/buffer_store.rs@@ -20,7 +20,7 @@ use language::{},};use rpc::{- AnyProtoClient, ErrorExt as _, TypedEnvelope,+ AnyProtoClient, ErrorCode, ErrorExt as _, TypedEnvelope,proto::{self, ToProto},};use smol::channel::Receiver;@@ -837,7 +837,15 @@ impl BufferStore {}};- cx.background_spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })+ cx.background_spawn(async move {+ task.await.map_err(|e| {+ if e.error_code() != ErrorCode::Internal {+ anyhow!(e.error_code())+ } else {+ anyhow!("{e}")+ }+ })+ })}pub fn create_buffer(&mut self, cx: &mut Context<Self>) -> Task<Result<Entity<Buffer>>> {@@ -944,7 +952,15 @@ impl BufferStore {) -> impl Iterator<Item = (&ProjectPath, impl Future<Output = Result<Entity<Buffer>>>)> {self.loading_buffers.iter().map(|(path, task)| {let task = task.clone();- (path, async move { task.await.map_err(|e| anyhow!("{e}")) })+ (path, async move {+ task.await.map_err(|e| {+ if e.error_code() != ErrorCode::Internal {+ anyhow!(e.error_code())+ } else {+ anyhow!("{e}")+ }+ })+ })})}diff --git a/crates/remote/src/remote_client.rs b/crates/remote/src/remote_client.rsindex dd529ca8749..7e231e622cb 100644--- a/crates/remote/src/remote_client.rs+++ b/crates/remote/src/remote_client.rs@@ -1117,7 +1117,7 @@ impl ChannelClient {}Err(error) => {log::error!(- "{}:error handling message. type:{}, error:{}",+ "{}:error handling message. type:{}, error:{:#}",this.name,type_name,format!("{error:#}").lines().fold(diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex 0f119c14003..61442eb6348 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -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)+ }}}))});