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:
Conrad Irwin
2025-09-18 21:13:49 +00:00
committed by GitHub
parent 5f4f0a873e
commit b09764c54a
74 changed files with 1089 additions and 2818 deletions
+1 -13
View File
@@ -2,7 +2,6 @@ use std::sync::atomic::{AtomicBool, Ordering};
use gpui::App;
use settings::{Settings, SettingsStore};
use util::MergeFrom as _;
#[derive(Clone, Debug)]
pub struct AudioSettings {
@@ -23,7 +22,7 @@ pub struct AudioSettings {
/// Configuration of audio in Zed
impl Settings for AudioSettings {
fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
let audio = &content.audio.as_ref().unwrap();
AudioSettings {
control_input_volume: audio.control_input_volume.unwrap(),
@@ -32,17 +31,6 @@ impl Settings for AudioSettings {
}
}
fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
let Some(audio) = content.audio.as_ref() else {
return;
};
self.control_input_volume
.merge_from(&audio.control_input_volume);
self.control_output_volume
.merge_from(&audio.control_output_volume);
self.rodio_audio.merge_from(&audio.rodio_audio);
}
fn import_from_vscode(
_vscode: &settings::VsCodeSettings,
_current: &mut settings::SettingsContent,