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:
@@ -1,7 +1,6 @@
|
||||
use dap_types::SteppingGranularity;
|
||||
use gpui::App;
|
||||
use settings::{Settings, SettingsContent};
|
||||
use util::MergeFrom;
|
||||
|
||||
pub struct DebuggerSettings {
|
||||
/// Determines the stepping granularity.
|
||||
@@ -35,7 +34,7 @@ pub struct DebuggerSettings {
|
||||
}
|
||||
|
||||
impl Settings for DebuggerSettings {
|
||||
fn from_defaults(content: &SettingsContent, _cx: &mut App) -> Self {
|
||||
fn from_settings(content: &SettingsContent, _cx: &mut App) -> Self {
|
||||
let content = content.debugger.clone().unwrap();
|
||||
Self {
|
||||
stepping_granularity: dap_granularity_from_settings(
|
||||
@@ -49,27 +48,6 @@ impl Settings for DebuggerSettings {
|
||||
dock: content.dock.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
fn refine(&mut self, content: &SettingsContent, _cx: &mut App) {
|
||||
let Some(content) = &content.debugger else {
|
||||
return;
|
||||
};
|
||||
self.stepping_granularity.merge_from(
|
||||
&content
|
||||
.stepping_granularity
|
||||
.map(dap_granularity_from_settings),
|
||||
);
|
||||
self.save_breakpoints.merge_from(&content.save_breakpoints);
|
||||
self.button.merge_from(&content.button);
|
||||
self.timeout.merge_from(&content.timeout);
|
||||
self.log_dap_communications
|
||||
.merge_from(&content.log_dap_communications);
|
||||
self.format_dap_log_messages
|
||||
.merge_from(&content.format_dap_log_messages);
|
||||
self.dock.merge_from(&content.dock);
|
||||
}
|
||||
|
||||
fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut SettingsContent) {}
|
||||
}
|
||||
|
||||
fn dap_granularity_from_settings(
|
||||
|
||||
Reference in New Issue
Block a user