Revert "settings: Remove auxiliary Content types where possible (#16744)" (#17768)

This breaks setting `{"scrollbar": {"show":"never"}}`
Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-09-12 14:46:08 -04:00 committed by GitHub
parent 3b37db4140
commit 4d26f83d23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 686 additions and 833 deletions

View file

@ -2289,7 +2289,7 @@ impl ProjectPanel {
.child(
ListItem::new(entry_id.to_proto() as usize)
.indent_level(depth)
.indent_step_size(settings.indent_size)
.indent_step_size(px(settings.indent_size))
.selected(is_marked || is_active)
.when_some(canonical_path, |this, path| {
this.end_slot::<AnyElement>(
@ -2817,7 +2817,7 @@ impl Render for DraggedProjectEntryView {
this.bg(cx.theme().colors().background).w(self.width).child(
ListItem::new(self.selection.entry_id.to_proto() as usize)
.indent_level(self.details.depth)
.indent_step_size(settings.indent_size)
.indent_step_size(px(settings.indent_size))
.child(if let Some(icon) = &self.details.icon {
div().child(Icon::from_path(icon.clone()))
} else {
@ -2855,7 +2855,7 @@ impl Panel for ProjectPanel {
DockPosition::Left | DockPosition::Bottom => ProjectPanelDockPosition::Left,
DockPosition::Right => ProjectPanelDockPosition::Right,
};
settings.dock = dock;
settings.dock = Some(dock);
},
);
}
@ -3029,7 +3029,7 @@ mod tests {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |worktree_settings| {
worktree_settings.file_scan_exclusions =
vec!["**/.git".to_string(), "**/4/**".to_string()];
Some(vec!["**/.git".to_string(), "**/4/**".to_string()]);
});
});
});
@ -4818,10 +4818,10 @@ mod tests {
cx.update(|cx| {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |worktree_settings| {
worktree_settings.file_scan_exclusions = Vec::new();
worktree_settings.file_scan_exclusions = Some(Vec::new());
});
store.update_user_settings::<ProjectPanelSettings>(cx, |project_panel_settings| {
project_panel_settings.auto_reveal_entries = false
project_panel_settings.auto_reveal_entries = Some(false)
});
})
});
@ -4940,7 +4940,7 @@ mod tests {
cx.update(|cx| {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<ProjectPanelSettings>(cx, |project_panel_settings| {
project_panel_settings.auto_reveal_entries = true
project_panel_settings.auto_reveal_entries = Some(true)
});
})
});
@ -5054,10 +5054,10 @@ mod tests {
cx.update(|cx| {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |worktree_settings| {
worktree_settings.file_scan_exclusions = Vec::new();
worktree_settings.file_scan_exclusions = Some(Vec::new());
});
store.update_user_settings::<ProjectPanelSettings>(cx, |project_panel_settings| {
project_panel_settings.auto_reveal_entries = false
project_panel_settings.auto_reveal_entries = Some(false)
});
})
});
@ -5256,7 +5256,7 @@ mod tests {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<WorktreeSettings>(cx, |project_settings| {
project_settings.file_scan_exclusions =
vec!["excluded_dir".to_string(), "**/.git".to_string()];
Some(vec!["excluded_dir".to_string(), "**/.git".to_string()]);
});
});
});
@ -5569,10 +5569,10 @@ mod tests {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<ProjectPanelSettings>(cx, |project_panel_settings| {
project_panel_settings.auto_fold_dirs = false;
project_panel_settings.auto_fold_dirs = Some(false);
});
store.update_user_settings::<WorktreeSettings>(cx, |worktree_settings| {
worktree_settings.file_scan_exclusions = Vec::new();
worktree_settings.file_scan_exclusions = Some(Vec::new());
});
});
});
@ -5591,10 +5591,10 @@ mod tests {
cx.update_global::<SettingsStore, _>(|store, cx| {
store.update_user_settings::<ProjectPanelSettings>(cx, |project_panel_settings| {
project_panel_settings.auto_fold_dirs = false;
project_panel_settings.auto_fold_dirs = Some(false);
});
store.update_user_settings::<WorktreeSettings>(cx, |worktree_settings| {
worktree_settings.file_scan_exclusions = Vec::new();
worktree_settings.file_scan_exclusions = Some(Vec::new());
});
});
});

View file

@ -2,7 +2,6 @@ use gpui::Pixels;
use schemars::JsonSchema;
use serde_derive::{Deserialize, Serialize};
use settings::{Settings, SettingsSources};
use ui::px;
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, Copy, PartialEq)]
#[serde(rename_all = "snake_case")]
@ -11,50 +10,20 @@ pub enum ProjectPanelDockPosition {
Right,
}
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq, JsonSchema)]
#[serde(default)]
#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
pub struct ProjectPanelSettings {
/// Whether to show the project panel button in the status bar.
pub button: bool,
/// Customize default width (in pixels) taken by project panel
pub default_width: Pixels,
/// The position of project panel
pub dock: ProjectPanelDockPosition,
/// Whether to show file icons in the project panel.
pub file_icons: bool,
/// Whether to show folder icons or chevrons for directories in the project panel.
pub folder_icons: bool,
/// Whether to show the git status in the project panel.
pub git_status: bool,
/// Amount of indentation (in pixels) for nested items.
pub indent_size: Pixels,
/// Whether to reveal it in the project panel automatically,
/// when a corresponding project entry becomes active.
/// Gitignored entries are never auto revealed.
pub indent_size: f32,
pub auto_reveal_entries: bool,
/// Whether to fold directories automatically
/// when directory has only one directory inside.
pub auto_fold_dirs: bool,
/// Scrollbar-related settings
pub scrollbar: ScrollbarSettings,
}
impl Default for ProjectPanelSettings {
fn default() -> Self {
Self {
button: true,
default_width: px(240.),
dock: ProjectPanelDockPosition::Left,
file_icons: true,
folder_icons: true,
git_status: true,
indent_size: px(20.),
auto_reveal_entries: true,
auto_fold_dirs: true,
scrollbar: Default::default(),
}
}
}
/// When to show the scrollbar in the project panel.
///
/// Default: always
@ -68,7 +37,7 @@ pub enum ShowScrollbar {
Never,
}
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
pub struct ScrollbarSettings {
/// When to show the scrollbar in the project panel.
///
@ -76,10 +45,63 @@ pub struct ScrollbarSettings {
pub show: ShowScrollbar,
}
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
pub struct ScrollbarSettingsContent {
/// When to show the scrollbar in the project panel.
///
/// Default: always
pub show: Option<ShowScrollbar>,
}
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
pub struct ProjectPanelSettingsContent {
/// Whether to show the project panel button in the status bar.
///
/// Default: true
pub button: Option<bool>,
/// Customize default width (in pixels) taken by project panel
///
/// Default: 240
pub default_width: Option<f32>,
/// The position of project panel
///
/// Default: left
pub dock: Option<ProjectPanelDockPosition>,
/// Whether to show file icons in the project panel.
///
/// Default: true
pub file_icons: Option<bool>,
/// Whether to show folder icons or chevrons for directories in the project panel.
///
/// Default: true
pub folder_icons: Option<bool>,
/// Whether to show the git status in the project panel.
///
/// Default: true
pub git_status: Option<bool>,
/// Amount of indentation (in pixels) for nested items.
///
/// Default: 20
pub indent_size: Option<f32>,
/// Whether to reveal it in the project panel automatically,
/// when a corresponding project entry becomes active.
/// Gitignored entries are never auto revealed.
///
/// Default: true
pub auto_reveal_entries: Option<bool>,
/// Whether to fold directories automatically
/// when directory has only one directory inside.
///
/// Default: false
pub auto_fold_dirs: Option<bool>,
/// Scrollbar-related settings
pub scrollbar: Option<ScrollbarSettingsContent>,
}
impl Settings for ProjectPanelSettings {
const KEY: Option<&'static str> = Some("project_panel");
type FileContent = Self;
type FileContent = ProjectPanelSettingsContent;
fn load(
sources: SettingsSources<Self::FileContent>,