Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
copilot: Colocate `copilot_chat_config_path` with the rest of the Copilot code (#15703)
Marshall Bowersd6e558e3c9ba
diff --git a/crates/copilot/src/copilot_chat.rs b/crates/copilot/src/copilot_chat.rsindex 4fe76e6e513..a2fca980a5b 100644--- a/crates/copilot/src/copilot_chat.rs+++ b/crates/copilot/src/copilot_chat.rs@@ -1,3 +1,5 @@+use std::path::PathBuf;+use std::sync::OnceLock;use std::{sync::Arc, time::Duration};use anyhow::{anyhow, Result};@@ -7,6 +9,7 @@ use futures::{io::BufReader, stream::BoxStream, AsyncBufReadExt, AsyncReadExt, Suse gpui::{AppContext, AsyncAppContext, Global};use http_client::{AsyncBody, HttpClient, Method, Request as HttpRequest};use isahc::config::Configurable;+use paths::home_dir;use serde::{Deserialize, Serialize};use settings::watch_config_file;use strum::EnumIter;@@ -164,6 +167,20 @@ pub fn init(fs: Arc<dyn Fs>, client: Arc<dyn HttpClient>, cx: &mut AppContext) {cx.set_global(GlobalCopilotChat(copilot_chat));}+fn copilot_chat_config_path() -> &'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")+ } else {+ home_dir().join(".config")+ }+ .join("github-copilot")+ .join("hosts.json")+ })+}+impl CopilotChat {pub fn global(cx: &AppContext) -> Option<gpui::Model<Self>> {cx.try_global::<GlobalCopilotChat>()@@ -174,7 +191,7 @@ impl CopilotChat {let mut config_file_rx = watch_config_file(cx.background_executor(),fs,- paths::copilot_chat_config_path().clone(),+ copilot_chat_config_path().clone(),);cx.spawn(|cx| async move {diff --git a/crates/paths/src/paths.rs b/crates/paths/src/paths.rsindex 1cbdd500c5b..768be162d27 100644--- a/crates/paths/src/paths.rs+++ b/crates/paths/src/paths.rs@@ -212,20 +212,6 @@ pub fn copilot_dir() -> &'static PathBuf {COPILOT_DIR.get_or_init(|| support_dir().join("copilot"))}-pub fn copilot_chat_config_path() -> &'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")- } else {- home_dir().join(".config")- }- .join("github-copilot")- .join("hosts.json")- })-}-/// Returns the path to the Supermaven directory.pub fn supermaven_dir() -> &'static PathBuf {static SUPERMAVEN_DIR: OnceLock<PathBuf> = OnceLock::new();