From 6b04b668ad884464264209cf92c1072a71bd41c8 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Fri, 21 Jun 2024 18:39:14 +0200 Subject: [PATCH] settings: Load `.zed/settings.json` even if .gitignored (#13370) This fixes #4432 by ensuring that we scan & watch the `.zed` folder, just like we watch the `.git`, for changes. Release Notes: - Settings are now loaded from local `.zed/settings.json` files even if they are `.gitignore`d. ([#4432](https://github.com/zed-industries/zed/issues/4432)). Co-authored-by: Bennet --- Cargo.lock | 1 + crates/paths/src/paths.rs | 6 ++++++ crates/worktree/Cargo.toml | 1 + crates/worktree/src/worktree.rs | 2 ++ 4 files changed, 10 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index eaf1cf3bb1..581df52c41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13082,6 +13082,7 @@ dependencies = [ "language", "log", "parking_lot", + "paths", "postage", "pretty_assertions", "rand 0.8.5", diff --git a/crates/paths/src/paths.rs b/crates/paths/src/paths.rs index a556cb5879..8f24873a8a 100644 --- a/crates/paths/src/paths.rs +++ b/crates/paths/src/paths.rs @@ -224,6 +224,12 @@ pub fn default_prettier_dir() -> &'static PathBuf { DEFAULT_PRETTIER_DIR.get_or_init(|| support_dir().join("prettier")) } +/// Returns the relative path to a `.zed` folder within a project. +pub fn local_settings_folder_relative_path() -> &'static Path { + static LOCAL_SETTINGS_FOLDER_RELATIVE_PATH: OnceLock<&Path> = OnceLock::new(); + LOCAL_SETTINGS_FOLDER_RELATIVE_PATH.get_or_init(|| Path::new(".zed")) +} + /// Returns the relative path to a `settings.json` file within a project. pub fn local_settings_file_relative_path() -> &'static Path { static LOCAL_SETTINGS_FILE_RELATIVE_PATH: OnceLock<&Path> = OnceLock::new(); diff --git a/crates/worktree/Cargo.toml b/crates/worktree/Cargo.toml index 75136352fc..cbb353b9d3 100644 --- a/crates/worktree/Cargo.toml +++ b/crates/worktree/Cargo.toml @@ -34,6 +34,7 @@ ignore.workspace = true language.workspace = true log.workspace = true parking_lot.workspace = true +paths.workspace = true postage.workspace = true rpc.workspace = true schemars.workspace = true diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index ca8465d914..7aeae0a065 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -31,6 +31,7 @@ use gpui::{ }; use ignore::IgnoreStack; use parking_lot::Mutex; +use paths::local_settings_folder_relative_path; use postage::{ barrier, prelude::{Sink as _, Stream as _}, @@ -2589,6 +2590,7 @@ impl BackgroundScannerState { fn should_scan_directory(&self, entry: &Entry) -> bool { (!entry.is_external && !entry.is_ignored) || entry.path.file_name() == Some(*DOT_GIT) + || entry.path.file_name() == Some(local_settings_folder_relative_path().as_os_str()) || self.scanned_dirs.contains(&entry.id) // If we've ever scanned it, keep scanning || self .paths_to_scan