mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Show full, absolute paths when displaying a local worktree
This commit is contained in:
parent
354fefe61b
commit
1f161b9aa1
@ -92,6 +92,9 @@ impl LineEnding {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct HomeDir(pub PathBuf);
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait Fs: Send + Sync {
|
||||
async fn create_dir(&self, path: &Path) -> Result<()>;
|
||||
|
@ -5,8 +5,8 @@ use anyhow::{anyhow, Context, Result};
|
||||
use client::{proto, Client};
|
||||
use clock::ReplicaId;
|
||||
use collections::{HashMap, VecDeque};
|
||||
use fs::LineEnding;
|
||||
use fs::{repository::GitRepository, Fs};
|
||||
use fs::{HomeDir, LineEnding};
|
||||
use futures::{
|
||||
channel::{
|
||||
mpsc::{self, UnboundedSender},
|
||||
@ -1839,7 +1839,23 @@ impl language::File for File {
|
||||
|
||||
fn full_path(&self, cx: &AppContext) -> PathBuf {
|
||||
let mut full_path = PathBuf::new();
|
||||
full_path.push(self.worktree.read(cx).root_name());
|
||||
let worktree = self.worktree.read(cx);
|
||||
if worktree.is_visible() {
|
||||
full_path.push(worktree.root_name());
|
||||
} else {
|
||||
let home_dir = cx.global::<HomeDir>();
|
||||
let local_path = worktree.as_local().map(|local| local.abs_path.clone());
|
||||
if let Some(path) = local_path {
|
||||
if let Ok(path) = path.strip_prefix(home_dir.0.as_path()) {
|
||||
full_path.push("~");
|
||||
full_path.push(path);
|
||||
} else {
|
||||
full_path.push(path)
|
||||
}
|
||||
} else {
|
||||
full_path.push(Path::new("/host-filesystem/"))
|
||||
}
|
||||
}
|
||||
if self.path.components().next().is_some() {
|
||||
full_path.push(&self.path);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ use isahc::{config::Configurable, Request};
|
||||
use language::LanguageRegistry;
|
||||
use log::LevelFilter;
|
||||
use parking_lot::Mutex;
|
||||
use project::{Fs, ProjectStore};
|
||||
use project::{Fs, HomeDir, ProjectStore};
|
||||
use serde_json::json;
|
||||
use settings::{
|
||||
self, settings_file::SettingsFile, KeymapFileContent, Settings, SettingsFileContent,
|
||||
@ -99,6 +99,8 @@ fn main() {
|
||||
|
||||
let (settings_file_content, keymap_file) = cx.background().block(config_files).unwrap();
|
||||
|
||||
cx.set_global(HomeDir(zed::paths::HOME.to_path_buf()));
|
||||
|
||||
//Setup settings global before binding actions
|
||||
cx.set_global(SettingsFile::new(
|
||||
&*zed::paths::SETTINGS,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref HOME: PathBuf = dirs::home_dir().expect("failed to determine home directory");
|
||||
pub static ref HOME: PathBuf = dirs::home_dir().expect("failed to determine home directory");
|
||||
pub static ref CONFIG_DIR: PathBuf = HOME.join(".config").join("zed");
|
||||
pub static ref LOGS_DIR: PathBuf = HOME.join("Library/Logs/Zed");
|
||||
pub static ref LANGUAGES_DIR: PathBuf = HOME.join("Library/Application Support/Zed/languages");
|
||||
|
Loading…
Reference in New Issue
Block a user