Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
copilot: Fix config dir logic to support Flatpak environments (#32901)
Umesh Yadave914d84f00df
diff --git a/Cargo.lock b/Cargo.lockindex 20f6fd29948..d3a623f7ef6 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -3346,6 +3346,7 @@ dependencies = ["collections","command_palette_hooks","ctor",+ "dirs 4.0.0","editor","fs","futures 0.3.31",diff --git a/crates/copilot/Cargo.toml b/crates/copilot/Cargo.tomlindex c859d912b41..234875d420b 100644--- a/crates/copilot/Cargo.toml+++ b/crates/copilot/Cargo.toml@@ -29,6 +29,7 @@ chrono.workspace = trueclient.workspace = truecollections.workspace = truecommand_palette_hooks.workspace = true+dirs.workspace = truefs.workspace = truefutures.workspace = truegpui.workspace = truediff --git a/crates/copilot/src/copilot_chat.rs b/crates/copilot/src/copilot_chat.rsindex 119098ef02e..54b82175961 100644--- a/crates/copilot/src/copilot_chat.rs+++ b/crates/copilot/src/copilot_chat.rs@@ -424,12 +424,15 @@ pub fn copilot_chat_config_dir() -> &'static PathBuf {static COPILOT_CHAT_CONFIG_DIR: OnceLock<PathBuf> = OnceLock::new();COPILOT_CHAT_CONFIG_DIR.get_or_init(|| {- if cfg!(target_os = "windows") {- home_dir().join("AppData").join("Local")+ let config_dir = if cfg!(target_os = "windows") {+ dirs::data_local_dir().expect("failed to determine LocalAppData directory")} else {- home_dir().join(".config")- }- .join("github-copilot")+ std::env::var("XDG_CONFIG_HOME")+ .map(PathBuf::from)+ .unwrap_or_else(|_| home_dir().join(".config"))+ };++ config_dir.join("github-copilot")})}