mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
editor: Use inclusive ranges for git diff resolution. (#3999)
The culprit was in display map which was resolving next valid point for the editor, without regard for whether that point belongs to the same excerpt. We now make an end point a minimum of the end point passed in and the start of excerpt header, if there are any. This bug existed in Zed1 as well. Fixes: Diff markers in multibuffer search overlap with dividers between excepts (shouldn't extend all the way into the divider region) Release Notes: - Fixed diff markers being drawn incorrectly near headers in multibuffer views.
This commit is contained in:
parent
f16331a331
commit
282184a673
@ -804,9 +804,22 @@ impl EditorElement {
|
||||
|
||||
let start_row = display_row_range.start;
|
||||
let end_row = display_row_range.end;
|
||||
// If we're in a multibuffer, row range span might include an
|
||||
// excerpt header, so if we were to draw the marker straight away,
|
||||
// the hunk might include the rows of that header.
|
||||
// Making the range inclusive doesn't quite cut it, as we rely on the exclusivity for the soft wrap.
|
||||
// Instead, we simply check whether the range we're dealing with includes
|
||||
// any custom elements and if so, we stop painting the diff hunk on the first row of that custom element.
|
||||
let end_row_in_current_excerpt = layout
|
||||
.position_map
|
||||
.snapshot
|
||||
.blocks_in_range(start_row..end_row)
|
||||
.next()
|
||||
.map(|(start_row, _)| start_row)
|
||||
.unwrap_or(end_row);
|
||||
|
||||
let start_y = start_row as f32 * line_height - scroll_top;
|
||||
let end_y = end_row as f32 * line_height - scroll_top;
|
||||
let end_y = end_row_in_current_excerpt as f32 * line_height - scroll_top;
|
||||
|
||||
let width = 0.275 * line_height;
|
||||
let highlight_origin = bounds.origin + point(-width, start_y);
|
||||
|
Loading…
Reference in New Issue
Block a user