Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

editor: Hide horizontal scrollbar if not visible (#23337)

Bennet Bo Fennerc929533e0045
diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs
index 404685ab3b9..74d20a5ed65 100644
--- a/crates/assistant/src/inline_assistant.rs
+++ b/crates/assistant/src/inline_assistant.rs
@@ -1206,6 +1206,7 @@ impl InlineAssistant {
editor.set_show_wrap_guides(false, cx);
editor.set_show_gutter(false, cx);
editor.scroll_manager.set_forbid_vertical_scroll(true);
+ editor.set_show_scrollbars(false, cx);
editor.set_read_only(true);
editor.set_show_inline_completions(Some(false), cx);
editor.highlight_rows::<DeletedLines>(
diff --git a/crates/assistant2/src/inline_assistant.rs b/crates/assistant2/src/inline_assistant.rs
index 15a0adeaa0d..69dd5987a38 100644
--- a/crates/assistant2/src/inline_assistant.rs
+++ b/crates/assistant2/src/inline_assistant.rs
@@ -1280,6 +1280,7 @@ impl InlineAssistant {
editor.set_show_wrap_guides(false, cx);
editor.set_show_gutter(false, cx);
editor.scroll_manager.set_forbid_vertical_scroll(true);
+ editor.set_show_scrollbars(false, cx);
editor.set_read_only(true);
editor.set_show_inline_completions(Some(false), cx);
editor.highlight_rows::<DeletedLines>(
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index bcb77404978..e4f526a992b 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -1335,11 +1335,15 @@ impl EditorElement {
total_text_units
.horizontal
.zip(track_bounds.horizontal)
- .map(|(total_text_units_x, track_bounds_x)| {
+ .and_then(|(total_text_units_x, track_bounds_x)| {
+ if text_units_per_page.horizontal >= total_text_units_x {
+ return None;
+ }
+
let thumb_percent =
(text_units_per_page.horizontal / total_text_units_x).min(1.);
- track_bounds_x.size.width * thumb_percent
+ Some(track_bounds_x.size.width * thumb_percent)
}),
total_text_units.vertical.zip(track_bounds.vertical).map(
|(total_text_units_y, track_bounds_y)| {