Mountain/IPC/WindServiceHandlers/Extension/UserExtensionDirectory.rs
1//! User-scope install destination for VSIX unpacks. Matches the user-scope
2//! scan path in `Binary/Extension/ScanPathConfigure.rs` so VSIX-installed
3//! extensions are discovered on the next Mountain boot without a sync step.
4//!
5//! Resolution order (honours Atom V1 `Lodge`):
6//! 1. `$Lodge` - explicit per-operator override. Leading `~/` expands against
7//! `$HOME`.
8//! 2. `$HOME/.fiddee/extensions` - VS Code-style user-scope default, resolved
9//! through `Utilities::FiddeeRoot`.
10//! 3. `./extensions` - fallback when `$HOME` is unavailable.
11
12use std::path::PathBuf;
13
14use crate::IPC::WindServiceHandlers::Utilities::FiddeeRoot::Fn as FiddeeRoot;
15
16pub fn Fn() -> PathBuf {
17 if let Ok(Override) = std::env::var("Lodge") {
18 if let Some(Stripped) = Override.strip_prefix("~/") {
19 if let Some(HomeDirectory) = dirs::home_dir() {
20 return HomeDirectory.join(Stripped);
21 }
22 }
23
24 return PathBuf::from(Override);
25 }
26
27 FiddeeRoot().join("extensions")
28}