1use editor::EditorSettings;
2use gpui::{App, Pixels};
3pub use settings::{DockSide, Settings, ShowIndentGuides};
4use ui::scrollbars::{ScrollbarVisibility, ShowScrollbar};
5
6#[derive(Debug, Clone, Copy, PartialEq)]
7pub struct OutlinePanelSettings {
8 pub button: bool,
9 pub default_width: Pixels,
10 pub dock: DockSide,
11 pub file_icons: bool,
12 pub folder_icons: bool,
13 pub git_status: bool,
14 pub indent_size: f32,
15 pub indent_guides: IndentGuidesSettings,
16 pub auto_reveal_entries: bool,
17 pub auto_fold_dirs: bool,
18 pub scrollbar: ScrollbarSettings,
19 pub expand_outlines_with_depth: usize,
20}
21
22#[derive(Copy, Clone, Debug, PartialEq, Eq)]
23pub struct ScrollbarSettings {
24 /// When to show the scrollbar in the project panel.
25 ///
26 /// Default: inherits editor scrollbar settings
27 pub show: Option<ShowScrollbar>,
28}
29
30#[derive(Copy, Clone, Debug, PartialEq, Eq)]
31pub struct IndentGuidesSettings {
32 pub show: ShowIndentGuides,
33}
34
35impl ScrollbarVisibility for OutlinePanelSettings {
36 fn visibility(&self, cx: &App) -> ShowScrollbar {
37 self.scrollbar
38 .show
39 .unwrap_or_else(|| EditorSettings::get_global(cx).scrollbar.show)
40 }
41}
42
43impl Settings for OutlinePanelSettings {
44 fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self {
45 let panel = content.outline_panel.as_ref().unwrap();
46 Self {
47 button: panel.button.unwrap(),
48 default_width: panel.default_width.map(gpui::px).unwrap(),
49 dock: panel.dock.unwrap(),
50 file_icons: panel.file_icons.unwrap(),
51 folder_icons: panel.folder_icons.unwrap(),
52 git_status: panel.git_status.unwrap(),
53 indent_size: panel.indent_size.unwrap(),
54 indent_guides: IndentGuidesSettings {
55 show: panel.indent_guides.unwrap().show.unwrap(),
56 },
57 auto_reveal_entries: panel.auto_reveal_entries.unwrap(),
58 auto_fold_dirs: panel.auto_fold_dirs.unwrap(),
59 scrollbar: ScrollbarSettings {
60 show: panel.scrollbar.unwrap().show.map(Into::into),
61 },
62 expand_outlines_with_depth: panel.expand_outlines_with_depth.unwrap(),
63 }
64 }
65
66 fn import_from_vscode(
67 vscode: &settings::VsCodeSettings,
68 current: &mut settings::SettingsContent,
69 ) {
70 if let Some(b) = vscode.read_bool("outline.icons") {
71 let outline_panel = current.outline_panel.get_or_insert_default();
72 outline_panel.file_icons = Some(b);
73 outline_panel.folder_icons = Some(b);
74 }
75
76 if let Some(b) = vscode.read_bool("git.decorations.enabled") {
77 let outline_panel = current.outline_panel.get_or_insert_default();
78 outline_panel.git_status = Some(b);
79 }
80 }
81}