Allow disabling editor scrollbars programmatically (#22333)
Disable them in the diff editors Closes https://github.com/zed-industries/zed/issues/22271 Release Notes: - N/A
This commit is contained in:
parent
1449377278
commit
2930211af9
5 changed files with 27 additions and 12 deletions
|
@ -1556,6 +1556,7 @@ impl ContextEditor {
|
||||||
let mut editor = Editor::for_buffer(context.read(cx).buffer().clone(), None, cx);
|
let mut editor = Editor::for_buffer(context.read(cx).buffer().clone(), None, cx);
|
||||||
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
|
editor.set_soft_wrap_mode(SoftWrap::EditorWidth, cx);
|
||||||
editor.set_show_line_numbers(false, 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_git_diff_gutter(false, cx);
|
||||||
editor.set_show_code_actions(false, cx);
|
editor.set_show_code_actions(false, cx);
|
||||||
editor.set_show_runnables(false, cx);
|
editor.set_show_runnables(false, cx);
|
||||||
|
|
|
@ -606,6 +606,7 @@ pub struct Editor {
|
||||||
mode: EditorMode,
|
mode: EditorMode,
|
||||||
show_breadcrumbs: bool,
|
show_breadcrumbs: bool,
|
||||||
show_gutter: bool,
|
show_gutter: bool,
|
||||||
|
show_scrollbars: bool,
|
||||||
show_line_numbers: Option<bool>,
|
show_line_numbers: Option<bool>,
|
||||||
use_relative_line_numbers: Option<bool>,
|
use_relative_line_numbers: Option<bool>,
|
||||||
show_git_diff_gutter: Option<bool>,
|
show_git_diff_gutter: Option<bool>,
|
||||||
|
@ -1235,6 +1236,7 @@ impl Editor {
|
||||||
project,
|
project,
|
||||||
blink_manager: blink_manager.clone(),
|
blink_manager: blink_manager.clone(),
|
||||||
show_local_selections: true,
|
show_local_selections: true,
|
||||||
|
show_scrollbars: true,
|
||||||
mode,
|
mode,
|
||||||
show_breadcrumbs: EditorSettings::get_global(cx).toolbar.breadcrumbs,
|
show_breadcrumbs: EditorSettings::get_global(cx).toolbar.breadcrumbs,
|
||||||
show_gutter: mode == EditorMode::Full,
|
show_gutter: mode == EditorMode::Full,
|
||||||
|
@ -11260,6 +11262,11 @@ impl Editor {
|
||||||
cx.notify();
|
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>) {
|
pub fn set_show_line_numbers(&mut self, show_line_numbers: bool, cx: &mut ViewContext<Self>) {
|
||||||
self.show_line_numbers = Some(show_line_numbers);
|
self.show_line_numbers = Some(show_line_numbers);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|
|
@ -1192,7 +1192,8 @@ impl EditorElement {
|
||||||
);
|
);
|
||||||
|
|
||||||
let scrollbar_settings = EditorSettings::get_global(cx).scrollbar;
|
let scrollbar_settings = EditorSettings::get_global(cx).scrollbar;
|
||||||
let show_scrollbars = match scrollbar_settings.show {
|
let show_scrollbars = self.editor.read(cx).show_scrollbars
|
||||||
|
&& match scrollbar_settings.show {
|
||||||
ShowScrollbar::Auto => {
|
ShowScrollbar::Auto => {
|
||||||
let editor = self.editor.read(cx);
|
let editor = self.editor.read(cx);
|
||||||
let is_singleton = editor.is_singleton(cx);
|
let is_singleton = editor.is_singleton(cx);
|
||||||
|
|
|
@ -1155,6 +1155,11 @@ fn editor_with_deleted_text(
|
||||||
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::None, cx);
|
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::None, cx);
|
||||||
editor.set_show_wrap_guides(false, cx);
|
editor.set_show_wrap_guides(false, cx);
|
||||||
editor.set_show_gutter(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.scroll_manager.set_forbid_vertical_scroll(true);
|
||||||
editor.set_read_only(true);
|
editor.set_read_only(true);
|
||||||
editor.set_show_inline_completions(Some(false), cx);
|
editor.set_show_inline_completions(Some(false), cx);
|
||||||
|
@ -1166,7 +1171,7 @@ fn editor_with_deleted_text(
|
||||||
false,
|
false,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
editor.set_current_line_highlight(Some(CurrentLineHighlight::None)); //
|
editor.set_current_line_highlight(Some(CurrentLineHighlight::None));
|
||||||
editor
|
editor
|
||||||
._subscriptions
|
._subscriptions
|
||||||
.extend([cx.on_blur(&editor.focus_handle, |editor, cx| {
|
.extend([cx.on_blur(&editor.focus_handle, |editor, cx| {
|
||||||
|
|
|
@ -269,6 +269,7 @@ impl RateCompletionModal {
|
||||||
let mut editor = Editor::multi_line(cx);
|
let mut editor = Editor::multi_line(cx);
|
||||||
editor.set_soft_wrap_mode(language_settings::SoftWrap::EditorWidth, cx);
|
editor.set_soft_wrap_mode(language_settings::SoftWrap::EditorWidth, cx);
|
||||||
editor.set_show_line_numbers(false, 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_git_diff_gutter(false, cx);
|
||||||
editor.set_show_code_actions(false, cx);
|
editor.set_show_code_actions(false, cx);
|
||||||
editor.set_show_runnables(false, cx);
|
editor.set_show_runnables(false, cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue