diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index f2937591a3..58bc064690 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
+ \t\t\t + \t\t
+ \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
+ \t\t\t + \t\t
+ \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.rs index 87f049330f..47302f9668 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 found let 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);