patch 9.1.0743: diff mode does not handle overlapping diffs correctly
Problem: diff mode does not handle overlapping diffs correctly
Solution: correct the logic to handle overlapping blocks
(Yukihiro Nakadaira)
Vim merges overlapped diff blocks and it doesn't work expectedly
in some situation.
closes: #15735
Signed-off-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/diff.c b/src/diff.c
index 70e2814..ebe409e 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1803,7 +1803,10 @@
{
for (i = idx_orig; i < idx_new; ++i)
if (curtab->tp_diffbuf[i] != NULL)
+ {
dp->df_lnum[i] -= off;
+ dp->df_count[i] += off;
+ }
dp->df_lnum[idx_new] = hunk->lnum_new;
dp->df_count[idx_new] = hunk->count_new;
}
@@ -1815,9 +1818,7 @@
}
else
// second overlap of new block with existing block
- dp->df_count[idx_new] += hunk->count_new - hunk->count_orig
- + dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]
- - (dp->df_lnum[idx_orig] + dp->df_count[idx_orig]);
+ dp->df_count[idx_new] += hunk->count_new;
// Adjust the size of the block to include all the lines to the
// end of the existing block or the new diff, whatever ends last.
@@ -1825,10 +1826,8 @@
- (dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]);
if (off < 0)
{
- // new change ends in existing block, adjust the end if not
- // done already
- if (notset)
- dp->df_count[idx_new] += -off;
+ // new change ends in existing block, adjust the end
+ dp->df_count[idx_new] += -off;
off = 0;
}
for (i = idx_orig; i < idx_new; ++i)