Skip to content

fix: Match rustc's first group trailing line #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/highlight_source.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 15 additions & 13 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,23 +351,25 @@ impl Renderer {
peek.is_some() || (g == 0 && group_len > 1),
);

if g == 0 && group_len > 1 {
if g == 0 {
let current_line = buffer.num_lines();
if matches!(peek, Some(Element::Title(level)) if level.level.name != Some(None))
{
self.draw_col_separator_no_space(
&mut buffer,
current_line,
max_line_num_len + 1,
);
// We want to draw the separator when it is
// requested, or when it is the last element
} else if peek.is_none() {
self.draw_col_separator_end(
match peek {
Some(Element::Title(level))
if level.level.name != Some(None) =>
{
self.draw_col_separator_no_space(
&mut buffer,
current_line,
max_line_num_len + 1,
);
}

None if group_len > 1 => self.draw_col_separator_end(
&mut buffer,
current_line,
max_line_num_len + 1,
);
),
_ => {}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,7 @@ LL │ ┃ Ok("")
LL │ ┃ ))))))))))))))))))))))))))))))
LL │ ┃ ))))))))))))))))))))))))))))));
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ expected `Atype<Btype<Ctype<..., i32>, i32>, i32>`, found `Result<Result<Result<..., _>, _>, _>`
├ note: expected struct `Atype<Btype<..., i32>, i32>`
│ found enum `Result<Result<..., _>, _>`
├ note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
Expand Down Expand Up @@ -2180,6 +2181,7 @@ error: expected item, found `?`
|
1 | ... 的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。*/?
| ^ expected item
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
"#]];

Expand All @@ -2191,6 +2193,7 @@ error: expected item, found `?`
1 │ … 宽的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。*/?
│ ━ expected item
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
"#]];
let renderer_unicode = renderer_ascii.theme(OutputTheme::Unicode);
Expand All @@ -2217,6 +2220,7 @@ error: expected item, found `?`
|
1 | ... 。这是宽的。这是宽的。这是宽的...
| ^^ expected item
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
"#]];

Expand All @@ -2228,6 +2232,7 @@ error: expected item, found `?`
1 │ … 的。这是宽的。这是宽的。这是宽的。…
│ ━━ expected item
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
"#]];
let renderer_unicode = renderer_ascii.theme(OutputTheme::Unicode);
Expand All @@ -2254,6 +2259,7 @@ error: expected item, found `?`
|
1 | ...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/?
| ^ expected item
|
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
"#]];

Expand All @@ -2265,6 +2271,7 @@ error: expected item, found `?`
1 │ …aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/?
│ ━ expected item
╰ note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
"#]];
let renderer_unicode = renderer_ascii.theme(OutputTheme::Unicode);
Expand Down