Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Allow disabling editor scrollbars programmatically (#22333)
Kirill Bulatov2930211af912
diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rsindex bfa82b7c401..27fbc774344 100644--- a/crates/assistant/src/assistant_panel.rs+++ b/crates/assistant/src/assistant_panel.rs@@ -1556,6 +1556,7 @@ impl ContextEditor {let mut editor = Editor::for_buffer(context.read(cx).buffer().clone(), None, cx);editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);editor.set_show_line_numbers(false, cx);+ editor.set_show_scrollbars(false, cx);editor.set_show_git_diff_gutter(false, cx);editor.set_show_code_actions(false, cx);editor.set_show_runnables(false, cx);diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex d0571f78fe1..ac6020767e2 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -606,6 +606,7 @@ pub struct Editor {mode: EditorMode,show_breadcrumbs: bool,show_gutter: bool,+ show_scrollbars: bool,show_line_numbers: Option<bool>,use_relative_line_numbers: Option<bool>,show_git_diff_gutter: Option<bool>,@@ -1235,6 +1236,7 @@ impl Editor {project,blink_manager: blink_manager.clone(),show_local_selections: true,+ show_scrollbars: true,mode,show_breadcrumbs: EditorSettings::get_global(cx).toolbar.breadcrumbs,show_gutter: mode == EditorMode::Full,@@ -11260,6 +11262,11 @@ impl Editor {cx.notify();}+ pub fn set_show_scrollbars(&mut self, show_scrollbars: bool, cx: &mut ViewContext<Self>) {+ self.show_scrollbars = show_scrollbars;+ cx.notify();+ }+pub fn set_show_line_numbers(&mut self, show_line_numbers: bool, cx: &mut ViewContext<Self>) {self.show_line_numbers = Some(show_line_numbers);cx.notify();diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 537ab003531..f44571701ff 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -1192,12 +1192,13 @@ impl EditorElement {);let scrollbar_settings = EditorSettings::get_global(cx).scrollbar;- let show_scrollbars = match scrollbar_settings.show {- ShowScrollbar::Auto => {- let editor = self.editor.read(cx);- let is_singleton = editor.is_singleton(cx);- // Git- (is_singleton && scrollbar_settings.git_diff && !snapshot.diff_map.is_empty())+ let show_scrollbars = self.editor.read(cx).show_scrollbars+ && match scrollbar_settings.show {+ ShowScrollbar::Auto => {+ let editor = self.editor.read(cx);+ let is_singleton = editor.is_singleton(cx);+ // Git+ (is_singleton && scrollbar_settings.git_diff && !snapshot.diff_map.is_empty())||// Buffer Search Results(is_singleton && scrollbar_settings.search_results && editor.has_background_highlights::<BufferSearchHighlights>())@@ -1213,11 +1214,11 @@ impl EditorElement {||// Scrollmanagereditor.scroll_manager.scrollbars_visible()- }- ShowScrollbar::System => self.editor.read(cx).scroll_manager.scrollbars_visible(),- ShowScrollbar::Always => true,- ShowScrollbar::Never => false,- };+ }+ ShowScrollbar::System => self.editor.read(cx).scroll_manager.scrollbars_visible(),+ ShowScrollbar::Always => true,+ ShowScrollbar::Never => false,+ };let axes: AxisPair<bool> = scrollbar_settings.axes.into();diff --git a/crates/editor/src/hunk_diff.rs b/crates/editor/src/hunk_diff.rsindex 76e7a920365..748aa3bd87a 100644--- a/crates/editor/src/hunk_diff.rs+++ b/crates/editor/src/hunk_diff.rs@@ -1155,6 +1155,11 @@ fn editor_with_deleted_text(editor.set_soft_wrap_mode(language::language_settings::SoftWrap::None, cx);editor.set_show_wrap_guides(false, cx);editor.set_show_gutter(false, cx);+ editor.set_show_line_numbers(false, cx);+ editor.set_show_scrollbars(false, cx);+ editor.set_show_runnables(false, cx);+ editor.set_show_git_diff_gutter(false, cx);+ editor.set_show_code_actions(false, cx);editor.scroll_manager.set_forbid_vertical_scroll(true);editor.set_read_only(true);editor.set_show_inline_completions(Some(false), cx);@@ -1166,7 +1171,7 @@ fn editor_with_deleted_text(false,cx,);- editor.set_current_line_highlight(Some(CurrentLineHighlight::None)); //+ editor.set_current_line_highlight(Some(CurrentLineHighlight::None));editor._subscriptions.extend([cx.on_blur(&editor.focus_handle, |editor, cx| {diff --git a/crates/zeta/src/rate_completion_modal.rs b/crates/zeta/src/rate_completion_modal.rsindex ba9375b7a34..99e1febd9bf 100644--- a/crates/zeta/src/rate_completion_modal.rs+++ b/crates/zeta/src/rate_completion_modal.rs@@ -269,6 +269,7 @@ impl RateCompletionModal {let mut editor = Editor::multi_line(cx);editor.set_soft_wrap_mode(language_settings::SoftWrap::EditorWidth, cx);editor.set_show_line_numbers(false, cx);+ editor.set_show_scrollbars(false, cx);editor.set_show_git_diff_gutter(false, cx);editor.set_show_code_actions(false, cx);editor.set_show_runnables(false, cx);