Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Expand tilde paths in edit prediction settings (#31235)
clauses3b798392050db
diff --git a/Cargo.lock b/Cargo.lockindex 12cc4f2928c..88283152ba0 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -8762,6 +8762,7 @@ dependencies = ["serde","serde_json","settings",+ "shellexpand 2.1.2","smallvec","smol","streaming-iterator",diff --git a/crates/language/Cargo.toml b/crates/language/Cargo.tomlindex ef1b0c195b0..a776790403b 100644--- a/crates/language/Cargo.toml+++ b/crates/language/Cargo.toml@@ -51,6 +51,7 @@ schemars.workspace = trueserde.workspace = trueserde_json.workspace = truesettings.workspace = true+shellexpand.workspace = truesmallvec.workspace = truesmol.workspace = truestreaming-iterator.workspace = truediff --git a/crates/language/src/language_settings.rs b/crates/language/src/language_settings.rsindex 6b7c59bae24..e36ea66164f 100644--- a/crates/language/src/language_settings.rs+++ b/crates/language/src/language_settings.rs@@ -23,6 +23,7 @@ use serde_json::Value;use settings::{Settings, SettingsLocation, SettingsSources, SettingsStore, add_references_to_properties,};+use shellexpand;use std::{borrow::Cow, num::NonZeroU32, path::Path, sync::Arc};use util::serde::default_true;@@ -1331,9 +1332,10 @@ impl settings::Settings for AllLanguageSettings {disabled_globs: completion_globs.iter().filter_map(|g| {+ let expanded_g = shellexpand::tilde(g).into_owned();Some(DisabledGlob {- matcher: globset::Glob::new(g).ok()?.compile_matcher(),- is_absolute: Path::new(g).is_absolute(),+ matcher: globset::Glob::new(&expanded_g).ok()?.compile_matcher(),+ is_absolute: Path::new(&expanded_g).is_absolute(),})}).collect(),@@ -1712,10 +1714,12 @@ mod tests {};#[cfg(windows)]let glob_str = glob_str.as_str();-+ let expanded_glob_str = shellexpand::tilde(glob_str).into_owned();DisabledGlob {- matcher: globset::Glob::new(glob_str).unwrap().compile_matcher(),- is_absolute: Path::new(glob_str).is_absolute(),+ matcher: globset::Glob::new(&expanded_glob_str)+ .unwrap()+ .compile_matcher(),+ is_absolute: Path::new(&expanded_glob_str).is_absolute(),}}).collect(),@@ -1811,6 +1815,12 @@ mod tests {let dot_env_file = make_test_file(&[".env"]);let settings = build_settings(&[".env"]);assert!(!settings.enabled_for_file(&dot_env_file, &cx));++ // Test tilde expansion+ let home = shellexpand::tilde("~").into_owned().to_string();+ let home_file = make_test_file(&[&home, "test.rs"]);+ let settings = build_settings(&["~/test.rs"]);+ assert!(!settings.enabled_for_file(&home_file, &cx));}#[test]diff --git a/docs/src/ai/edit-prediction.md b/docs/src/ai/edit-prediction.mdindex 264e89a8d30..13f75e71da7 100644--- a/docs/src/ai/edit-prediction.md+++ b/docs/src/ai/edit-prediction.md@@ -231,6 +231,18 @@ To not have predictions appear automatically as you type when working with a spe}```+### In Specific Directories++To disable edit predictions for specific directories or files, set this within `settings.json`:++```json+{+ "edit_predictions": {+ "disabled_globs": ["~/.config/zed/settings.json"]+ }+}+```+### Turning Off CompletelyTo completely turn off edit prediction across all providers, explicitly set the settings to `none`, like so: