Skip to content

Commit 070723f

Browse files
committed
fix: Correctly calculate row for diff suggestion
1 parent b500cd4 commit 070723f

File tree

5 files changed

+20
-17
lines changed

5 files changed

+20
-17
lines changed

src/renderer/render.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,7 +1774,10 @@ fn emit_suggestion_default(
17741774
// too bad to begin with, so we side-step that issue here.
17751775
for (i, line) in snippet.lines().enumerate() {
17761776
let line = normalize_whitespace(line);
1777-
let row = row_num - 2 - (newlines - i - 1);
1777+
// Going lower than buffer_offset (+ 1) would mean
1778+
// overwriting existing content in the buffer
1779+
let min_row = buffer_offset + usize::from(!matches_previous_suggestion);
1780+
let row = (row_num - 2 - (newlines - i - 1)).max(min_row);
17781781
// On the first line, we highlight between the start of the part
17791782
// span, and the end of that line.
17801783
// On the last line, we highlight between the start of the line, and

tests/color/highlight_duplicated_diff_lines.ascii.term.svg

Lines changed: 2 additions & 2 deletions
Loading

tests/color/highlight_duplicated_diff_lines.unicode.term.svg

Lines changed: 2 additions & 2 deletions
Loading

tests/color/multiple_highlight_duplicated.ascii.term.svg

Lines changed: 6 additions & 6 deletions
Loading

tests/color/multiple_highlight_duplicated.unicode.term.svg

Lines changed: 6 additions & 6 deletions
Loading

0 commit comments

Comments
 (0)