settings: Remove auxiliary Content types where possible (#16744)
Release Notes: - N/A
This commit is contained in:
parent
8f28445612
commit
ccf6f27b8f
49 changed files with 843 additions and 696 deletions
|
@ -2289,7 +2289,7 @@ impl ProjectPanel {
|
|||
.child(
|
||||
ListItem::new(entry_id.to_proto() as usize)
|
||||
.indent_level(depth)
|
||||
.indent_step_size(px(settings.indent_size))
|
||||
.indent_step_size(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(px(settings.indent_size))
|
||||
.indent_step_size(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 = Some(dock);
|
||||
settings.dock = 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 =
|
||||
Some(vec!["**/.git".to_string(), "**/4/**".to_string()]);
|
||||
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 = Some(Vec::new());
|
||||
worktree_settings.file_scan_exclusions = Vec::new();
|
||||
});
|
||||
store.update_user_settings::<ProjectPanelSettings>(cx, |project_panel_settings| {
|
||||
project_panel_settings.auto_reveal_entries = Some(false)
|
||||
project_panel_settings.auto_reveal_entries = 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 = Some(true)
|
||||
project_panel_settings.auto_reveal_entries = 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 = Some(Vec::new());
|
||||
worktree_settings.file_scan_exclusions = Vec::new();
|
||||
});
|
||||
store.update_user_settings::<ProjectPanelSettings>(cx, |project_panel_settings| {
|
||||
project_panel_settings.auto_reveal_entries = Some(false)
|
||||
project_panel_settings.auto_reveal_entries = 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 =
|
||||
Some(vec!["excluded_dir".to_string(), "**/.git".to_string()]);
|
||||
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 = Some(false);
|
||||
project_panel_settings.auto_fold_dirs = false;
|
||||
});
|
||||
store.update_user_settings::<WorktreeSettings>(cx, |worktree_settings| {
|
||||
worktree_settings.file_scan_exclusions = Some(Vec::new());
|
||||
worktree_settings.file_scan_exclusions = 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 = Some(false);
|
||||
project_panel_settings.auto_fold_dirs = false;
|
||||
});
|
||||
store.update_user_settings::<WorktreeSettings>(cx, |worktree_settings| {
|
||||
worktree_settings.file_scan_exclusions = Some(Vec::new());
|
||||
worktree_settings.file_scan_exclusions = Vec::new();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ 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")]
|
||||
|
@ -10,20 +11,50 @@ pub enum ProjectPanelDockPosition {
|
|||
Right,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Deserialize, Serialize, Debug, Clone, Copy, PartialEq, JsonSchema)]
|
||||
#[serde(default)]
|
||||
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,
|
||||
pub indent_size: f32,
|
||||
/// 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 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
|
||||
|
@ -37,7 +68,7 @@ pub enum ShowScrollbar {
|
|||
Never,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||
pub struct ScrollbarSettings {
|
||||
/// When to show the scrollbar in the project panel.
|
||||
///
|
||||
|
@ -45,63 +76,10 @@ 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 = ProjectPanelSettingsContent;
|
||||
type FileContent = Self;
|
||||
|
||||
fn load(
|
||||
sources: SettingsSources<Self::FileContent>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue