From da422e7dcd27e2963cdceab47a4b80797e260d3e Mon Sep 17 00:00:00 2001 From: Junkui Zhang <364772080@qq.com> Date: Wed, 30 Apr 2025 16:28:24 +0800 Subject: [PATCH] Fix `vscode_settings_file` for Windows --- crates/paths/src/paths.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/crates/paths/src/paths.rs b/crates/paths/src/paths.rs index 088189f814..f2085ab199 100644 --- a/crates/paths/src/paths.rs +++ b/crates/paths/src/paths.rs @@ -430,15 +430,30 @@ pub fn global_ssh_config_file() -> &'static Path { pub fn vscode_settings_file() -> &'static PathBuf { static LOGS_DIR: OnceLock = OnceLock::new(); let rel_path = "Code/User/settings.json"; - LOGS_DIR.get_or_init(|| { - if cfg!(target_os = "macos") { - home_dir() - .join("Library/Application Support") + #[cfg(target_os = "macos")] + { + LOGS_DIR.get_or_init(|| { + if cfg!(target_os = "macos") { + home_dir() + .join("Library/Application Support") + .join(rel_path) + } else { + home_dir().join(".config").join(rel_path) + } + }) + } + #[cfg(target_os = "windows")] + { + LOGS_DIR.get_or_init(|| { + dirs::config_dir() + .expect("failed to determine RoamingAppData directory") .join(rel_path) - } else { - home_dir().join(".config").join(rel_path) - } - }) + }) + } + #[cfg(not(any(target_os = "macis", target_os = "windows")))] + { + LOGS_DIR.get_or_init(|| config_dir().join(rel_path)) + } } /// Returns the path to the cursor user settings file