Skip to content
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
6 changes: 4 additions & 2 deletions examples/multislice.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/renderer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,16 @@ impl Renderer {
margin,
);

// If there are no annotations, we are done
if line_info.annotations.is_empty() {
// `close_window` normally gets handled later, but we are early
// returning, so it needs to be handled here
if close_window {
self.draw_col_separator_end(buffer, line_offset + 1, width_offset - 2);
}
return vec![];
}

// Special case when there's only one annotation involved, it is the start of a multiline
// span and there's no text at the beginning of the code line. Instead of doing the whole
// graph:
Expand Down
4 changes: 3 additions & 1 deletion tests/color/ann_multiline2.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion tests/color/multiple_annotations.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions tests/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ error:
|
5402 | This is line 1
5403 | This is line 2
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -203,6 +204,7 @@ error:
╭▸
5402 │ This is line 1
5403 │ This is line 2
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -234,6 +236,7 @@ error:
::: file2.rs:2
|
2 | This is slice 2
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -247,6 +250,7 @@ error:
⸬ file2.rs:2
2 │ This is slice 2
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -340,6 +344,7 @@ error:
|
56 | This is an example
57 | of content lines
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -349,6 +354,7 @@ error:
╭▸
56 │ This is an example
57 │ of content lines
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -427,6 +433,7 @@ error:
--> file.rs
|
1 |
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -436,6 +443,7 @@ error:
╭▸ file.rs
1 │
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand All @@ -456,6 +464,7 @@ LL | This is an example
LL | of content lines
LL |
LL | abc
|
"#]];
let renderer = Renderer::plain().anonymized_line_numbers(true);
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -467,6 +476,7 @@ LL │ This is an example
LL │ of content lines
LL │
LL │ abc
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -561,6 +571,7 @@ error:
3 | a
| ^
4 | b
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -572,6 +583,7 @@ error:
3 │ a
│ ━
4 │ b
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -629,6 +641,7 @@ error:
2 | | にちは
| |_^
3 | 世界
|
"#]];

let renderer = Renderer::plain();
Expand All @@ -643,6 +656,7 @@ error:
2 │ ┃ にちは
│ ┗━┛
3 │ 世界
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -699,6 +713,7 @@ error:
3 | a
| ^
4 | b
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -710,6 +725,7 @@ error:
3 │ a
│ ━
4 │ b
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -803,6 +819,7 @@ error:
3 | a
| ^
4 | b
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -814,6 +831,7 @@ error:
3 │ a
│ ━
4 │ b
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand All @@ -838,6 +856,7 @@ error:
2 | | にちは
| |_^
3 | 世界
|
"#]];

let renderer = Renderer::plain();
Expand All @@ -852,6 +871,7 @@ error:
2 │ ┃ にちは
│ ┗━┛
3 │ 世界
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -981,6 +1001,7 @@ error:
2 | | にちは
| |__^
3 | 世界
|
"#]];

let renderer = Renderer::plain();
Expand All @@ -995,6 +1016,7 @@ error:
2 │ ┃ にちは
│ ┗━━┛
3 │ 世界
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -1057,6 +1079,7 @@ error:
4 | | b
| |__^
5 | c
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -1070,6 +1093,7 @@ error:
4 │ ┃ b
│ ┗━━┛
5 │ c
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -1444,6 +1468,7 @@ error: title
3 | ccc
| ^^^ annotation
4 | ddd
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -1457,6 +1482,7 @@ error: title
3 │ ccc
│ ━━━ annotation
4 │ ddd
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -1487,6 +1513,7 @@ error: title
3 | ccc
| ^^ annotation
4 | ddd
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -1500,6 +1527,7 @@ error: title
3 │ ccc
│ ━━ annotation
4 │ ddd
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -3467,6 +3495,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
12 | crazy
13 | quack
14 | zappy
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -3482,6 +3511,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
12 │ crazy
13 │ quack
14 │ zappy
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand All @@ -3505,6 +3535,7 @@ fn empty_span_start_line() {
| ^ E112
10 | #: E113
11 | print()
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -3517,6 +3548,7 @@ fn empty_span_start_line() {
│ ━ E112
10 │ #: E113
11 │ print()
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -3973,6 +4005,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
| ^^^^^
...
18 | zappy
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -3984,6 +4017,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
│ ━━━━━
18 │ zappy
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down Expand Up @@ -4019,6 +4053,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
| ^^^^^
13 | fuzzy
14 | pizza
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input), expected_ascii);
Expand All @@ -4030,6 +4065,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
│ ━━━━━
13 │ fuzzy
14 │ pizza
╰╴
"#]];
let renderer = renderer.decor_style(DecorStyle::Unicode);
assert_data_eq!(renderer.render(input), expected_unicode);
Expand Down
Loading