Skip to content

Commit b8ac403

Browse files
committed
chore!: Make fold the default
1 parent 2db78b7 commit b8ac403

19 files changed

+96
-196
lines changed

benches/bench.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,11 @@ fn fold(bencher: divan::Bencher<'_, '_>, context: usize) {
7171
.bench_values(|(input, span)| {
7272
let message = &[
7373
Group::with_title(Level::ERROR.title("mismatched types").id("E0308")).element(
74-
Snippet::source(&input)
75-
.fold(true)
76-
.path("src/format.rs")
77-
.annotation(
78-
AnnotationKind::Context
79-
.span(span)
80-
.label("expected `Option<String>` because of return type"),
81-
),
74+
Snippet::source(&input).path("src/format.rs").annotation(
75+
AnnotationKind::Context
76+
.span(span)
77+
.label("expected `Option<String>` because of return type"),
78+
),
8279
),
8380
];
8481

examples/custom_error.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ pub static C: u32 = 0 - 1;
2222
.id("E0080"),
2323
)
2424
.element(
25-
Snippet::source(source)
26-
.path("$DIR/err.rs")
27-
.fold(true)
28-
.annotation(
29-
AnnotationKind::Primary
30-
.span(386..391)
31-
.label("attempt to compute `0_u32 - 1_u32`, which would overflow"),
32-
),
25+
Snippet::source(source).path("$DIR/err.rs").annotation(
26+
AnnotationKind::Primary
27+
.span(386..391)
28+
.label("attempt to compute `0_u32 - 1_u32`, which would overflow"),
29+
),
3330
)];
3431

3532
let renderer = Renderer::styled().theme(OutputTheme::Unicode);

examples/custom_level.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ fn main() {
3939
Snippet::source(source)
4040
.line_start(1)
4141
.path("$DIR/issue-114529-illegal-break-with-value.rs")
42-
.fold(true)
4342
.annotation(
4443
AnnotationKind::Primary
4544
.span(483..581)
@@ -60,7 +59,6 @@ fn main() {
6059
Snippet::source(source)
6160
.line_start(1)
6261
.path("$DIR/issue-114529-illegal-break-with-value.rs")
63-
.fold(true)
6462
.patch(Patch::new(483..581, "break")),
6563
),
6664
];

examples/expected_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ fn main() {
1111
Snippet::source(source)
1212
.line_start(26)
1313
.path("examples/footer.rs")
14-
.fold(true)
1514
.annotation(AnnotationKind::Primary.span(193..195).label(
1615
"expected struct `annotate_snippets::snippet::Slice`, found reference",
1716
))

examples/format.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ fn main() {
2828
Snippet::source(source)
2929
.line_start(51)
3030
.path("src/format.rs")
31+
.fold(false)
3132
.annotation(
3233
AnnotationKind::Context
3334
.span(5..19)

examples/highlight_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {}
1313
.id("E0010"))
1414
.element(
1515
Snippet::source(source)
16-
.fold(true)
16+
1717
.path("$DIR/E0010-teach.rs")
1818
.annotation(
1919
AnnotationKind::Primary

examples/highlight_title.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ fn main() {
4545
Group::with_title(Level::ERROR.title("mismatched types").id("E0308"))
4646
.element(
4747
Snippet::source(source)
48-
.fold(true)
4948
.path("$DIR/highlighting.rs")
5049
.annotation(
5150
AnnotationKind::Primary
@@ -61,7 +60,6 @@ fn main() {
6160
.element(Level::NOTE.pre_styled_title(&title)),
6261
Group::with_title(Level::NOTE.title("function defined here")).element(
6362
Snippet::source(source)
64-
.fold(true)
6563
.path("$DIR/highlighting.rs")
6664
.annotation(AnnotationKind::Context.span(200..333).label(""))
6765
.annotation(AnnotationKind::Primary.span(194..199)),

examples/id_hyperlink.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ fn main() {
1717
Snippet::source(source)
1818
.line_start(1)
1919
.path("$DIR/terminal_urls.rs")
20-
.fold(true)
2120
.annotation(
2221
AnnotationKind::Primary
2322
.span(59..61)

examples/multislice.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ fn main() {
55
.element(
66
Snippet::<Annotation<'_>>::source("Foo")
77
.line_start(51)
8+
.fold(false)
89
.path("src/format.rs"),
910
)
1011
.element(
1112
Snippet::<Annotation<'_>>::source("Faa")
1213
.line_start(129)
14+
.fold(false)
1315
.path("src/display.rs"),
1416
)];
1517

src/renderer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
//! Snippet::source(source)
3030
//! .path("temp.rs")
3131
//! .line_start(1)
32-
//! .fold(true)
32+
//!
3333
//! .annotation(
3434
//! AnnotationKind::Primary
3535
//! .span(10..13)

src/snippet.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a, T: Clone> Snippet<'a, T> {
168168
line_start: 1,
169169
source: source.into(),
170170
markers: vec![],
171-
fold: false,
171+
fold: true,
172172
}
173173
}
174174

tests/color/fold_ann_multiline.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ fn case() {
3333
Snippet::source(source)
3434
.path("src/format.rs")
3535
.line_start(51)
36-
.fold(true)
3736
.annotation(AnnotationKind::Context.span(5..19).label(
3837
"expected `std::option::Option<std::string::String>` because of return type",
3938
))

tests/color/fold_bad_origin_line.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ invalid syntax
1313
Snippet::source(source)
1414
.path("path/to/error.rs")
1515
.line_start(1)
16-
.fold(true)
1716
.annotation(AnnotationKind::Context.span(2..16).label("error here")),
1817
)];
1918
let expected = file!["fold_bad_origin_line.term.svg"];

tests/color/fold_leading.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ workspace = 20
2626
Snippet::source(source)
2727
.path("Cargo.toml")
2828
.line_start(1)
29-
.fold(true)
3029
.annotation(AnnotationKind::Primary.span(132..134).label("")),
3130
)];
3231
let expected = file!["fold_leading.term.svg"];

tests/color/fold_trailing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ edition = "2021"
2525
Snippet::source(source)
2626
.path("Cargo.toml")
2727
.line_start(1)
28-
.fold(true)
2928
.annotation(AnnotationKind::Primary.span(8..10).label("")),
3029
)];
3130
let expected = file!["fold_trailing.term.svg"];

tests/color/multiline_removal_suggestion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn main() {}
7373
.element(
7474
Snippet::source(source)
7575
.path("$DIR/multiline-removal-suggestion.rs")
76-
.fold(true)
76+
7777
.annotation(
7878
AnnotationKind::Primary
7979
.span(769..776)
@@ -96,7 +96,7 @@ fn main() {}
9696
Group::with_title(Level::HELP.title("consider removing this method call, as the receiver has type `std::vec::IntoIter<HashSet<u8>>` and `std::vec::IntoIter<HashSet<u8>>: Iterator` trivially holds")).element(
9797
Snippet::source(source)
9898
.path("$DIR/multiline-removal-suggestion.rs")
99-
.fold(true)
99+
100100
.patch(Patch::new(708..768, "")),
101101
),
102102
];

tests/color/multiple_annotations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn case() {
1818
let input = &[Group::with_title(Level::ERROR.title("")).element(
1919
Snippet::source(source)
2020
.line_start(96)
21+
.fold(false)
2122
.annotation(
2223
AnnotationKind::Primary
2324
.span(100..110)

0 commit comments

Comments
 (0)