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: Fix horizontal scrollbar alignment if indent guides are disabled (#31621)

Finn Evers1035c6aab570
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 915524f9323..b1eabec4b5b 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -1512,6 +1512,17 @@ impl EditorElement {
ShowScrollbar::Never => return None,
};
+ // The horizontal scrollbar is usually slightly offset to align nicely with
+ // indent guides. However, this offset is not needed if indent guides are
+ // disabled for the current editor.
+ let content_offset = self
+ .editor
+ .read(cx)
+ .show_indent_guides
+ .is_none_or(|should_show| should_show)
+ .then_some(content_offset)
+ .unwrap_or_default();
+
Some(EditorScrollbars::from_scrollbar_axes(
ScrollbarAxes {
horizontal: scrollbar_settings.axes.horizontal