Adjust scrollbar settings to be expandable
This commit is contained in:
parent
9c32b774aa
commit
366f13bb5c
4 changed files with 45 additions and 31 deletions
|
@ -52,7 +52,9 @@
|
||||||
// 3. Draw all invisible symbols:
|
// 3. Draw all invisible symbols:
|
||||||
// "all"
|
// "all"
|
||||||
"show_whitespaces": "selection",
|
"show_whitespaces": "selection",
|
||||||
// Whether to show the scrollbar in the editor.
|
// Scrollbar related settings
|
||||||
|
"scrollbar": {
|
||||||
|
// When to show the scrollbar in the editor.
|
||||||
// This setting can take four values:
|
// This setting can take four values:
|
||||||
//
|
//
|
||||||
// 1. Show the scrollbar if there's important information or
|
// 1. Show the scrollbar if there's important information or
|
||||||
|
@ -64,7 +66,10 @@
|
||||||
// "always"
|
// "always"
|
||||||
// 4. Never show the scrollbar:
|
// 4. Never show the scrollbar:
|
||||||
// "never"
|
// "never"
|
||||||
"show_scrollbars": "auto",
|
"when_to_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.
|
// Whether the screen sharing icon is shown in the os status bar.
|
||||||
"show_call_status_icon": true,
|
"show_call_status_icon": true,
|
||||||
// Whether to use language servers to provide code intelligence.
|
// Whether to use language servers to provide code intelligence.
|
||||||
|
|
|
@ -533,12 +533,6 @@ pub struct EditorSnapshot {
|
||||||
ongoing_scroll: OngoingScroll,
|
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)]
|
#[derive(Clone, Debug)]
|
||||||
struct SelectionHistoryEntry {
|
struct SelectionHistoryEntry {
|
||||||
selections: Arc<[Selection<Anchor>]>,
|
selections: Arc<[Selection<Anchor>]>,
|
||||||
|
|
|
@ -7,12 +7,18 @@ pub struct EditorSettings {
|
||||||
pub cursor_blink: bool,
|
pub cursor_blink: bool,
|
||||||
pub hover_popover_enabled: bool,
|
pub hover_popover_enabled: bool,
|
||||||
pub show_completions_on_input: bool,
|
pub show_completions_on_input: bool,
|
||||||
pub show_scrollbars: ShowScrollbars,
|
pub scrollbar: Scrollbar,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||||
|
pub struct Scrollbar {
|
||||||
|
pub when_to_show: ShowScrollbar,
|
||||||
|
pub git_diff: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum ShowScrollbars {
|
pub enum ShowScrollbar {
|
||||||
Auto,
|
Auto,
|
||||||
System,
|
System,
|
||||||
Always,
|
Always,
|
||||||
|
@ -24,7 +30,13 @@ pub struct EditorSettingsContent {
|
||||||
pub cursor_blink: Option<bool>,
|
pub cursor_blink: Option<bool>,
|
||||||
pub hover_popover_enabled: Option<bool>,
|
pub hover_popover_enabled: Option<bool>,
|
||||||
pub show_completions_on_input: Option<bool>,
|
pub show_completions_on_input: Option<bool>,
|
||||||
pub show_scrollbars: Option<ShowScrollbars>,
|
pub scrollbar: Option<ScrollbarContent>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||||
|
pub struct ScrollbarContent {
|
||||||
|
pub when_to_show: Option<ShowScrollbar>,
|
||||||
|
pub git_diff: Option<bool>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Setting for EditorSettings {
|
impl Setting for EditorSettings {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use super::{
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
display_map::{BlockStyle, DisplaySnapshot, FoldStatus, TransformBlock},
|
display_map::{BlockStyle, DisplaySnapshot, FoldStatus, TransformBlock},
|
||||||
editor_settings::ShowScrollbars,
|
editor_settings::ShowScrollbar,
|
||||||
git::{diff_hunk_to_display, DisplayDiffHunk},
|
git::{diff_hunk_to_display, DisplayDiffHunk},
|
||||||
hover_popover::{
|
hover_popover::{
|
||||||
hide_hover, hover_at, HOVER_POPOVER_GAP, MIN_POPOVER_CHARACTER_WIDTH,
|
hide_hover, hover_at, HOVER_POPOVER_GAP, MIN_POPOVER_CHARACTER_WIDTH,
|
||||||
|
@ -1052,7 +1052,7 @@ impl EditorElement {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
|
|
||||||
if layout.is_singleton {
|
if layout.is_singleton && settings::get::<EditorSettings>(cx).scrollbar.git_diff {
|
||||||
let diff_style = theme::current(cx).editor.diff.clone();
|
let diff_style = theme::current(cx).editor.diff.clone();
|
||||||
for hunk in layout
|
for hunk in layout
|
||||||
.position_map
|
.position_map
|
||||||
|
@ -2067,14 +2067,17 @@ impl Element<Editor> for EditorElement {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let show_scrollbars = match settings::get::<EditorSettings>(cx).show_scrollbars {
|
let scrollbar_settings = &settings::get::<EditorSettings>(cx).scrollbar;
|
||||||
ShowScrollbars::Auto => {
|
let show_scrollbars = match scrollbar_settings.when_to_show {
|
||||||
snapshot.has_scrollbar_info(is_singleton)
|
ShowScrollbar::Auto => {
|
||||||
|
// Git
|
||||||
|
(is_singleton && scrollbar_settings.git_diff && snapshot.buffer_snapshot.has_git_diffs())
|
||||||
|
// Scrollmanager
|
||||||
|| editor.scroll_manager.scrollbars_visible()
|
|| editor.scroll_manager.scrollbars_visible()
|
||||||
}
|
}
|
||||||
ShowScrollbars::System => editor.scroll_manager.scrollbars_visible(),
|
ShowScrollbar::System => editor.scroll_manager.scrollbars_visible(),
|
||||||
ShowScrollbars::Always => true,
|
ShowScrollbar::Always => true,
|
||||||
ShowScrollbars::Never => false,
|
ShowScrollbar::Never => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let include_root = editor
|
let include_root = editor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue