Skip to content

Commit 17e474a

Browse files
committed
fix(libscoop): updated Config struct
Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
1 parent 2f58173 commit 17e474a

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

crates/libscoop/src/config.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub enum IsolatedPath {
208208
Boolean(bool),
209209

210210
/// string type of `use_isolated_path` indicating the environment variable name
211-
Name(String),
211+
Named(String),
212212
}
213213

214214
impl FromStr for IsolatedPath {
@@ -226,7 +226,7 @@ impl FromStr for IsolatedPath {
226226
match s.as_str() {
227227
"true" => Ok(IsolatedPath::Boolean(true)),
228228
"false" => Ok(IsolatedPath::Boolean(false)),
229-
_ => Ok(IsolatedPath::Name(s)),
229+
_ => Ok(IsolatedPath::Named(s)),
230230
}
231231
}
232232
}
@@ -265,18 +265,24 @@ impl Config {
265265
self.no_junction.unwrap_or_default()
266266
}
267267

268-
/// Get the `proxy` setting.
268+
/// Get the `proxy` config.
269269
#[inline]
270270
pub fn proxy(&self) -> Option<&str> {
271271
self.proxy.as_deref()
272272
}
273273

274-
/// Get the `cat_style` setting.
274+
/// Get the `cat_style` config.
275275
#[inline]
276276
pub fn cat_style(&self) -> &str {
277277
self.cat_style.as_deref().unwrap_or_default()
278278
}
279279

280+
/// Get the `use_isoloated_path` config.
281+
#[inline]
282+
pub fn use_isolated_path(&self) -> Option<&IsolatedPath> {
283+
self.use_isolated_path.as_ref()
284+
}
285+
280286
/// Update config key with new value.
281287
pub(crate) fn set(&mut self, key: &str, value: &str) -> Fallible<()> {
282288
let is_unset = value.is_empty();

crates/libscoop/src/internal/env.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ mod windows {
4040
let path = Path::new("Environment");
4141
let (env, _) = HKCU.create_subkey(path)?;
4242

43-
if value.is_none() {
44-
// ignore error of deleting non-existent value
45-
let _ = env.delete_value(key);
46-
} else {
47-
env.set_value(key, value.unwrap())?;
43+
match value {
44+
Some(value) => env.set_value(key, value)?,
45+
None => {
46+
// ignore error of deleting non-existent value
47+
let _ = env.delete_value(key);
48+
}
4849
}
4950
Ok(())
5051
}

0 commit comments

Comments
 (0)