settings: Use a derive macro for refine (#38451)
When we refactored settings to not pass JSON blobs around, we ended up needing to write *a lot* of code that just merged things (like json merge used to do). Use a derive macro to prevent typos in this logic. Release Notes: - N/A
This commit is contained in:
@@ -58,17 +58,14 @@ pub struct GitHostingProviderSettings {
|
||||
}
|
||||
|
||||
impl Settings for GitHostingProviderSettings {
|
||||
fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
|
||||
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
|
||||
Self {
|
||||
git_hosting_providers: content.project.git_hosting_providers.clone().unwrap(),
|
||||
git_hosting_providers: content
|
||||
.project
|
||||
.git_hosting_providers
|
||||
.clone()
|
||||
.unwrap()
|
||||
.into(),
|
||||
}
|
||||
}
|
||||
|
||||
fn refine(&mut self, content: &settings::SettingsContent, _: &mut App) {
|
||||
if let Some(more) = &content.project.git_hosting_providers {
|
||||
self.git_hosting_providers.extend_from_slice(&more.clone());
|
||||
}
|
||||
}
|
||||
|
||||
fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut settings::SettingsContent) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user