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
This commit is contained in:
@@ -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::<Buffer>()?;
|
||||
let buffer_id = BufferId::from(reservation.entity_id().as_non_zero_u64());
|
||||
|
||||
@@ -97,6 +97,7 @@ pub enum CreatedEntry {
|
||||
Excluded { abs_path: PathBuf },
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LoadedFile {
|
||||
pub file: Arc<File>,
|
||||
pub text: String,
|
||||
|
||||
Reference in New Issue
Block a user