From 717d898692f38c60c9e91f8b4a69ea679cdc3b30 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 12 Dec 2025 01:20:25 +0200 Subject: [PATCH] Show an underlying reason on file opening (#44664) Based on the debug attempt from https://github.com/zed-industries/zed/issues/44370 Release Notes: - N/A --- crates/project/src/buffer_store.rs | 18 ++---------------- crates/worktree/src/worktree.rs | 1 + 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index c38b898f5d79cf34563daa9bc7563f3c869d9a70..aea2482c83edb952f3b0dba03a510085c7c4d3f6 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -24,7 +24,7 @@ use rpc::{ use std::{io, sync::Arc, time::Instant}; use text::{BufferId, ReplicaId}; -use util::{ResultExt as _, TryFutureExt, debug_panic, maybe, paths::PathStyle, rel_path::RelPath}; +use util::{ResultExt as _, TryFutureExt, debug_panic, maybe, rel_path::RelPath}; use worktree::{File, PathChange, ProjectEntryId, Worktree, WorktreeId}; /// A set of open buffers. @@ -620,21 +620,7 @@ impl LocalBufferStore { let load_file = worktree.update(cx, |worktree, cx| worktree.load_file(path.as_ref(), cx)); cx.spawn(async move |this, cx| { let path = path.clone(); - let single_file_path = cx.update(|cx| { - if worktree.read(cx).is_single_file() { - Some(worktree.read(cx).abs_path()) - } else { - None - } - })?; - let path_string = single_file_path - .as_ref() - .map(|path| path.to_string_lossy()) - .unwrap_or_else(|| path.display(PathStyle::local())); - let buffer = match load_file - .await - .with_context(|| format!("Opening path \"{path_string}\"")) - { + let buffer = match load_file.await { Ok(loaded) => { let reservation = cx.reserve_entity::()?; let buffer_id = BufferId::from(reservation.entity_id().as_non_zero_u64()); diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index ca7fda9d716b611d0b6e85ee33775c98930b8907..d6e75e20fc425235f9ad22e85cb79f1585aac7d1 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -97,6 +97,7 @@ pub enum CreatedEntry { Excluded { abs_path: PathBuf }, } +#[derive(Debug)] pub struct LoadedFile { pub file: Arc, pub text: String,