diff --git a/assets/settings/default.json b/assets/settings/default.json index 1395edca4ab6f4339e8689e7aea48c1b5f531dc8..c4441651e6ecc69dc3cff92aae66a2b136652ac4 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -43,19 +43,24 @@ // 3. Draw all invisible symbols: // "all" "show_whitespaces": "selection", - // Whether to show the scrollbar in the editor. - // This setting can take four values: - // - // 1. Show the scrollbar if there's important information or - // follow the system's configured behavior (default): - // "auto" - // 2. Match the system's configured behavior: - // "system" - // 3. Always show the scrollbar: - // "always" - // 4. Never show the scrollbar: - // "never" - "show_scrollbars": "auto", + // Scrollbar related settings + "scrollbar": { + // When to show the scrollbar in the editor. + // This setting can take four values: + // + // 1. Show the scrollbar if there's important information or + // follow the system's configured behavior (default): + // "auto" + // 2. Match the system's configured behavior: + // "system" + // 3. Always show the scrollbar: + // "always" + // 4. Never show the scrollbar: + // "never" + "show": "auto", + // Whether to show git diff indicators in the scrollbar. + "git_diff": true + }, // Whether the screen sharing icon is shown in the os status bar. "show_call_status_icon": true, // Whether to use language servers to provide code intelligence. diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 244c5adaec4d6bf2689f32524500bcb013d5f89d..4088352a0b8fec602534119011a55d9bf02975a0 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -517,12 +517,6 @@ pub struct EditorSnapshot { ongoing_scroll: OngoingScroll, } -impl EditorSnapshot { - fn has_scrollbar_info(&self, is_singleton: bool) -> bool { - is_singleton && self.buffer_snapshot.has_git_diffs() - } -} - #[derive(Clone, Debug)] struct SelectionHistoryEntry { selections: Arc<[Selection]>, diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index f3be5ae6e2f1a40c9aa841ad883ecb89032430a6..f76362c9be880afb00a0d2af2f616bc2be9e102b 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1047,7 +1047,7 @@ impl EditorElement { ..Default::default() }); - if layout.is_singleton { + if layout.is_singleton && cx.global::().scrollbar.git_diff.unwrap_or(true) { let diff_style = cx.global::().theme.editor.diff.clone(); for hunk in layout .position_map @@ -2065,14 +2065,17 @@ impl Element for EditorElement { )); } - let show_scrollbars = match cx.global::().show_scrollbars { - settings::ShowScrollbars::Auto => { - snapshot.has_scrollbar_info(is_singleton) - || editor.scroll_manager.scrollbars_visible() + let scrollbar_settings = cx.global::().scrollbar; + let show_scrollbars = match scrollbar_settings.show.unwrap_or_default() { + settings::ShowScrollbar::Auto => { + // Git + (is_singleton && scrollbar_settings.git_diff.unwrap_or(true) && snapshot.buffer_snapshot.has_git_diffs()) + // Scrollmanager + || editor.scroll_manager.scrollbars_visible() } - settings::ShowScrollbars::System => editor.scroll_manager.scrollbars_visible(), - settings::ShowScrollbars::Always => true, - settings::ShowScrollbars::Never => false, + settings::ShowScrollbar::System => editor.scroll_manager.scrollbars_visible(), + settings::ShowScrollbar::Always => true, + settings::ShowScrollbar::Never => false, }; let include_root = editor diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs index 55598845c7b1daa17f524f35b1e6aff9a3ba4053..b361b3d6cbbbca7d905629e7e7d756dc1e8cd6da 100644 --- a/crates/settings/src/settings.rs +++ b/crates/settings/src/settings.rs @@ -46,7 +46,7 @@ pub struct Settings { pub hover_popover_enabled: bool, pub show_completions_on_input: bool, pub show_call_status_icon: bool, - pub show_scrollbars: ShowScrollbars, + pub scrollbar: Scrollbar, pub vim_mode: bool, pub autosave: Autosave, pub default_dock_anchor: DockAnchor, @@ -69,9 +69,15 @@ pub struct Settings { pub base_keymap: BaseKeymap, } +#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)] +pub struct Scrollbar { + pub show: Option, + pub git_diff: Option, +} + #[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)] #[serde(rename_all = "snake_case")] -pub enum ShowScrollbars { +pub enum ShowScrollbar { #[default] Auto, System, @@ -401,7 +407,7 @@ pub struct SettingsFileContent { #[serde(default)] pub active_pane_magnification: Option, #[serde(default)] - pub show_scrollbars: Option, + pub scrollbar: Option, #[serde(default)] pub cursor_blink: Option, #[serde(default)] @@ -560,7 +566,7 @@ impl Settings { features: Features { copilot: defaults.features.copilot.unwrap(), }, - show_scrollbars: defaults.show_scrollbars.unwrap(), + scrollbar: defaults.scrollbar.unwrap(), } } @@ -612,7 +618,7 @@ impl Settings { merge(&mut self.autosave, data.autosave); merge(&mut self.default_dock_anchor, data.default_dock_anchor); merge(&mut self.base_keymap, data.base_keymap); - merge(&mut self.show_scrollbars, data.show_scrollbars); + merge(&mut self.scrollbar, data.scrollbar); merge(&mut self.features.copilot, data.features.copilot); if let Some(copilot) = data.copilot { @@ -845,7 +851,7 @@ impl Settings { auto_update: true, base_keymap: Default::default(), features: Features { copilot: true }, - show_scrollbars: Default::default(), + scrollbar: Default::default(), } }