Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Return back the logic for indent guides check (#22095)
Kirill Bulatov91fdb5d2a9b7
diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex 8ff7c1cacd3..84f811645ef 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -13078,6 +13078,7 @@ fn assert_indent_guides(let indent_guides = cx.update_editor(|editor, cx| {let snapshot = editor.snapshot(cx).display_snapshot;let mut indent_guides: Vec<_> = crate::indent_guides::indent_guides_in_range(+ editor,MultiBufferRow(range.start)..MultiBufferRow(range.end),true,&snapshot,diff --git a/crates/editor/src/indent_guides.rs b/crates/editor/src/indent_guides.rsindex 1e04fe4b73d..1284ba81560 100644--- a/crates/editor/src/indent_guides.rs+++ b/crates/editor/src/indent_guides.rs@@ -56,6 +56,7 @@ impl Editor {}Some(indent_guides_in_range(+ self,visible_buffer_range,self.should_show_indent_guides() == Some(true),snapshot,@@ -152,6 +153,7 @@ impl Editor {}pub fn indent_guides_in_range(+ editor: &Editor,visible_buffer_range: Range<MultiBufferRow>,ignore_disabled_for_language: bool,snapshot: &DisplaySnapshot,@@ -169,10 +171,20 @@ pub fn indent_guides_in_range(.indent_guides_in_range(start_anchor..end_anchor, ignore_disabled_for_language, cx).into_iter().filter(|indent_guide| {+ if editor.buffer_folded(indent_guide.buffer_id, cx) {+ return false;+ }+let start =MultiBufferRow(indent_guide.multibuffer_row_range.start.0.saturating_sub(1));// Filter out indent guides that are inside a fold- !snapshot.is_line_folded(start)+ // All indent guides that are starting "offscreen" have a start value of the first visible row minus one+ // Therefore checking if a line is folded at first visible row minus one causes the other indent guides that are not related to the fold to disappear as well+ let is_folded = snapshot.is_line_folded(start);+ let line_indent = snapshot.line_indent_for_buffer_row(start);+ let contained_in_fold =+ line_indent.len(indent_guide.tab_size) <= indent_guide.indent_level();+ !(is_folded && contained_in_fold)}).collect()}