Settings refactor (#38367)
Co-Authored-By: Ben K <ben@zed.dev> Co-Authored-By: Anthony <anthony@zed.dev> Co-Authored-By: Mikayla <mikayla@zed.dev> Release Notes: - settings: Major internal changes to settings. The primary user-facing effect is that some settings which did not make sense in project settings files are no-longer read from there. (For example the inline blame settings) --------- Co-authored-by: Ben Kunkle <ben@zed.dev> Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com> Co-authored-by: Anthony <anthony@zed.dev>
This commit is contained in:
co-authored by
Ben Kunkle
Mikayla Maki
Anthony
parent
0a9023bce0
commit
fcdab160f9
@@ -1,16 +1,13 @@
|
||||
use fs::Fs;
|
||||
use gpui::{App, RenderOnce, SharedString};
|
||||
|
||||
use crate::{Settings, update_settings_file};
|
||||
use crate::{settings_content::SettingsContent, update_settings_file};
|
||||
|
||||
/// A UI control that can be used to edit a setting.
|
||||
pub trait EditableSettingControl: RenderOnce {
|
||||
/// The type of the setting value.
|
||||
type Value: Send;
|
||||
|
||||
/// The settings type to which this setting belongs.
|
||||
type Settings: Settings;
|
||||
|
||||
/// Returns the name of this setting.
|
||||
fn name(&self) -> SharedString;
|
||||
|
||||
@@ -20,17 +17,13 @@ pub trait EditableSettingControl: RenderOnce {
|
||||
/// Applies the given setting file to the settings file contents.
|
||||
///
|
||||
/// This will be called when writing the setting value back to the settings file.
|
||||
fn apply(
|
||||
settings: &mut <Self::Settings as Settings>::FileContent,
|
||||
value: Self::Value,
|
||||
cx: &App,
|
||||
);
|
||||
fn apply(settings: &mut SettingsContent, value: Self::Value, cx: &App);
|
||||
|
||||
/// Writes the given setting value to the settings files.
|
||||
fn write(value: Self::Value, cx: &App) {
|
||||
let fs = <dyn Fs>::global(cx);
|
||||
|
||||
update_settings_file::<Self::Settings>(fs, cx, move |settings, cx| {
|
||||
update_settings_file(fs, cx, move |settings, cx| {
|
||||
Self::apply(settings, value, cx);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user