From 6e55eccc4ab63394b3221c4c51fe09cfdc8a330f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 21 Mar 2024 14:41:10 -0500 Subject: [PATCH] fix(render): Fold like rustc Before, we elided all small sets of unhighlighted lines and then partially elided large sets of unhighlighted lines (favoring the start). In contrast, rustc shows 2 lines of context, split between the start and end of the fold. If there are 3 unhighlighted lines, it just skips folding. This makes a lot more sense. See https://github.com/rust-lang/rust/blob/2627e9f3012a97d3136b3e11bf6bd0853c38a534/compiler/rustc_errors/src/emitter.rs#L1878C17-L1939C18 In contrast to rustc, I made the amount of context a variable to make the intent clearer and to open the door to it being configurable. --- examples/expected_type.svg | 14 +- src/renderer/display_list.rs | 130 ++++++------------ .../fixtures/no-color/fold_ann_multiline.svg | 18 +-- 3 files changed, 59 insertions(+), 103 deletions(-) diff --git a/examples/expected_type.svg b/examples/expected_type.svg index ae06504..a355dbc 100644 --- a/examples/expected_type.svg +++ b/examples/expected_type.svg @@ -1,4 +1,4 @@ - +