Skip to content

Commit 14fb674

Browse files
committed
fix: Match rustc's first group trailing line
1 parent a65bbc2 commit 14fb674

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

examples/highlight_source.svg

Lines changed: 5 additions & 3 deletions
Loading

src/renderer/mod.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,23 +351,25 @@ impl Renderer {
351351
peek.is_some() || (g == 0 && group_len > 1),
352352
);
353353

354-
if g == 0 && group_len > 1 {
354+
if g == 0 {
355355
let current_line = buffer.num_lines();
356-
if matches!(peek, Some(Element::Title(level)) if level.level.name != Some(None))
357-
{
358-
self.draw_col_separator_no_space(
359-
&mut buffer,
360-
current_line,
361-
max_line_num_len + 1,
362-
);
363-
// We want to draw the separator when it is
364-
// requested, or when it is the last element
365-
} else if peek.is_none() {
366-
self.draw_col_separator_end(
356+
match peek {
357+
Some(Element::Title(level))
358+
if level.level.name != Some(None) =>
359+
{
360+
self.draw_col_separator_no_space(
361+
&mut buffer,
362+
current_line,
363+
max_line_num_len + 1,
364+
);
365+
}
366+
367+
None if group_len > 1 => self.draw_col_separator_end(
367368
&mut buffer,
368369
current_line,
369370
max_line_num_len + 1,
370-
);
371+
),
372+
_ => {}
371373
}
372374
}
373375
}

tests/formatter.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,6 +2021,7 @@ LL │ ┃ Ok("")
20212021
LL │ ┃ ))))))))))))))))))))))))))))))
20222022
LL │ ┃ ))))))))))))))))))))))))))))));
20232023
│ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ expected `Atype<Btype<Ctype<..., i32>, i32>, i32>`, found `Result<Result<Result<..., _>, _>, _>`
2024+
20242025
├ note: expected struct `Atype<Btype<..., i32>, i32>`
20252026
│ found enum `Result<Result<..., _>, _>`
20262027
├ note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt'
@@ -2180,6 +2181,7 @@ error: expected item, found `?`
21802181
|
21812182
1 | ... 的。这是宽的。这是宽的。这是宽的。这是宽的。这是宽的。*/?
21822183
| ^ expected item
2184+
|
21832185
= note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html>
21842186
"#]];
21852187

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

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

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

0 commit comments

Comments
 (0)