@@ -120,7 +120,7 @@ struct AutoUpdateSetting(bool);
/// Default: true
#[derive(Clone, Copy, Default, JsonSchema, Deserialize, Serialize, SettingsUi)]
#[serde(transparent)]
-struct AutoUpdateSettingContent(bool);
+struct AutoUpdateSettingContent(Option<bool>);
impl Settings for AutoUpdateSetting {
const KEY: Option<&'static str> = Some("auto_update");
@@ -135,17 +135,18 @@ impl Settings for AutoUpdateSetting {
sources.user,
]
.into_iter()
- .find_map(|value| value.copied())
- .unwrap_or(*sources.default);
+ .find_map(|value| value.and_then(|val| val.0))
+ .or(sources.default.0)
+ .ok_or_else(Self::missing_default)?;
- Ok(Self(auto_update.0))
+ Ok(Self(auto_update))
}
fn import_from_vscode(vscode: &settings::VsCodeSettings, current: &mut Self::FileContent) {
let mut cur = &mut Some(*current);
vscode.enum_setting("update.mode", &mut cur, |s| match s {
- "none" | "manual" => Some(AutoUpdateSettingContent(false)),
- _ => Some(AutoUpdateSettingContent(true)),
+ "none" | "manual" => Some(AutoUpdateSettingContent(Some(false))),
+ _ => Some(AutoUpdateSettingContent(Some(true))),
});
*current = cur.unwrap();
}