From 3ae646386962afb99a803707d1fcc70643492d89 Mon Sep 17 00:00:00 2001 From: Andrew Lygin Date: Fri, 5 Apr 2024 11:17:39 +0300 Subject: [PATCH] Fix scrollbar markers in large files (#10181) #10080 introduced a minor change in how the min marker height is enforced. Before the change, it was applied to the aggregated marker, but after the change it's applied to each individual marker before aggregation. The difference is not noticeable on small files, where even single row markers are higher than `MIN_MARKER_HEIGHT`, but it leads to visible differences in large files with repeating blocks of highlighted and not-highlighted blocks, like in [this case](https://github.com/zed-industries/zed/pull/9080#issuecomment-2006796376). This PR fixes how the `MIN_MARKER_HEIGHT` is applied. Before the fix: zed-scroll-markers-before After the fix: zed-scroll-markers-after Release Notes: - N/A /cc @mrnugget --- crates/editor/src/element.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 26ba2f0647..2f96b3ef42 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -3875,10 +3875,7 @@ impl ScrollbarLayout { .into_iter() .map(|range| { let start_y = self.first_row_y_offset + range.start as f32 * self.row_height; - let mut end_y = self.first_row_y_offset + (range.end + 1) as f32 * self.row_height; - if end_y - start_y < Self::MIN_MARKER_HEIGHT { - end_y = start_y + Self::MIN_MARKER_HEIGHT; - } + let end_y = self.first_row_y_offset + (range.end + 1) as f32 * self.row_height; ColoredRange { start: start_y, end: end_y, @@ -3889,11 +3886,14 @@ impl ScrollbarLayout { let mut quads = Vec::new(); while let Some(mut pixel_range) = background_pixel_ranges.next() { + pixel_range.end = pixel_range + .end + .max(pixel_range.start + Self::MIN_MARKER_HEIGHT); while let Some(next_pixel_range) = background_pixel_ranges.peek() { if pixel_range.end >= next_pixel_range.start && pixel_range.color == next_pixel_range.color { - pixel_range.end = next_pixel_range.end; + pixel_range.end = next_pixel_range.end.max(pixel_range.end); background_pixel_ranges.next(); } else { break;