Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
indent guides: Fix issue with entirely-whitespace lines (#31916)
Bennet Bo Fennerec69b68e7291
diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex f2937591a32..58bc0646905 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -17127,6 +17127,64 @@ async fn test_indent_guide_ends_before_empty_line(cx: &mut TestAppContext) {);}+#[gpui::test]+async fn test_indent_guide_ignored_only_whitespace_lines(cx: &mut TestAppContext) {+ let (buffer_id, mut cx) = setup_indent_guides_editor(+ &"+ function component() {+ \treturn (+ \t\t\t+ \t\t<div>+ \t\t\t<abc></abc>+ \t\t</div>+ \t)+ }"+ .unindent(),+ cx,+ )+ .await;++ assert_indent_guides(+ 0..8,+ vec![+ indent_guide(buffer_id, 1, 6, 0),+ indent_guide(buffer_id, 2, 5, 1),+ indent_guide(buffer_id, 4, 4, 2),+ ],+ None,+ &mut cx,+ );+}++#[gpui::test]+async fn test_indent_guide_fallback_to_next_non_entirely_whitespace_line(cx: &mut TestAppContext) {+ let (buffer_id, mut cx) = setup_indent_guides_editor(+ &"+ function component() {+ \treturn (+ \t+ \t\t<div>+ \t\t\t<abc></abc>+ \t\t</div>+ \t)+ }"+ .unindent(),+ cx,+ )+ .await;++ assert_indent_guides(+ 0..8,+ vec![+ indent_guide(buffer_id, 1, 6, 0),+ indent_guide(buffer_id, 2, 5, 1),+ indent_guide(buffer_id, 4, 4, 2),+ ],+ None,+ &mut cx,+ );+}+#[gpui::test]async fn test_indent_guide_continuing_off_screen(cx: &mut TestAppContext) {let (buffer_id, mut cx) = setup_indent_guides_editor(diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rsindex 87f049330fc..47302f96686 100644--- a/crates/multi_buffer/src/multi_buffer.rs+++ b/crates/multi_buffer/src/multi_buffer.rs@@ -5780,7 +5780,7 @@ impl MultiBufferSnapshot {// then add to the indent stack with the depth foundlet mut found_indent = false;let mut last_row = first_row;- if line_indent.is_line_empty() {+ if line_indent.is_line_blank() {while !found_indent {let Some((target_row, new_line_indent, _)) = row_indents.next() else {break;@@ -5790,7 +5790,7 @@ impl MultiBufferSnapshot {break;}- if new_line_indent.is_line_empty() {+ if new_line_indent.is_line_blank() {continue;}last_row = target_row.min(end_row);