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:
@@ -9,7 +9,6 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
use util::MergeFrom;
|
||||
use workspace::{AppState, OpenVisible, Workspace};
|
||||
|
||||
actions!(
|
||||
@@ -34,7 +33,7 @@ pub struct JournalSettings {
|
||||
}
|
||||
|
||||
impl settings::Settings for JournalSettings {
|
||||
fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
|
||||
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
|
||||
let journal = content.journal.clone().unwrap();
|
||||
|
||||
Self {
|
||||
@@ -42,14 +41,6 @@ impl settings::Settings for JournalSettings {
|
||||
hour_format: journal.hour_format.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
|
||||
let Some(journal) = content.journal.as_ref() else {
|
||||
return;
|
||||
};
|
||||
self.path.merge_from(&journal.path);
|
||||
self.hour_format.merge_from(&journal.hour_format);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(_: Arc<AppState>, cx: &mut App) {
|
||||
|
||||
Reference in New Issue
Block a user