copilot: Fix config dir logic to support Flatpak environments (#32901)
Closes #30784 In github copilot we were not handling the config path correctly for FLATPAK. * Only tested on mac don't have access to other platform. But this should work on other platform as well. It follows the similar pattern seen in zed config path resolution. - [x] Macos - [ ] Linux - [ ] Linux with Flatpak - [ ] Windows Release Notes: - Fix copilot config detection for flatpack
This commit is contained in:
parent
ec0f2fa79a
commit
e914d84f00
3 changed files with 10 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -3346,6 +3346,7 @@ dependencies = [
|
||||||
"collections",
|
"collections",
|
||||||
"command_palette_hooks",
|
"command_palette_hooks",
|
||||||
"ctor",
|
"ctor",
|
||||||
|
"dirs 4.0.0",
|
||||||
"editor",
|
"editor",
|
||||||
"fs",
|
"fs",
|
||||||
"futures 0.3.31",
|
"futures 0.3.31",
|
||||||
|
|
|
@ -29,6 +29,7 @@ chrono.workspace = true
|
||||||
client.workspace = true
|
client.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
command_palette_hooks.workspace = true
|
command_palette_hooks.workspace = true
|
||||||
|
dirs.workspace = true
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
|
|
|
@ -424,12 +424,15 @@ pub fn copilot_chat_config_dir() -> &'static PathBuf {
|
||||||
static COPILOT_CHAT_CONFIG_DIR: OnceLock<PathBuf> = OnceLock::new();
|
static COPILOT_CHAT_CONFIG_DIR: OnceLock<PathBuf> = OnceLock::new();
|
||||||
|
|
||||||
COPILOT_CHAT_CONFIG_DIR.get_or_init(|| {
|
COPILOT_CHAT_CONFIG_DIR.get_or_init(|| {
|
||||||
if cfg!(target_os = "windows") {
|
let config_dir = if cfg!(target_os = "windows") {
|
||||||
home_dir().join("AppData").join("Local")
|
dirs::data_local_dir().expect("failed to determine LocalAppData directory")
|
||||||
} else {
|
} else {
|
||||||
home_dir().join(".config")
|
std::env::var("XDG_CONFIG_HOME")
|
||||||
}
|
.map(PathBuf::from)
|
||||||
.join("github-copilot")
|
.unwrap_or_else(|_| home_dir().join(".config"))
|
||||||
|
};
|
||||||
|
|
||||||
|
config_dir.join("github-copilot")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue