indent guides: Fix issue with entirely-whitespace lines (#31916)

Closes #26957

Release Notes:

- Fix an edge case where indent guides would be rendered incorrectly if
lines consisted of entirely whitespace

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
Bennet Bo Fenner 2025-06-02 19:35:00 +02:00 committed by GitHub
parent 9dd18e5ee1
commit ec69b68e72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 60 additions and 2 deletions

View file

@ -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(