mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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>
This commit is contained in:
committed by
Christian Brabandt
parent
c854efc6fe
commit
06fe70c183
13
src/diff.c
13
src/diff.c
@@ -1803,7 +1803,10 @@ diff_read(
|
||||
{
|
||||
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 @@ diff_read(
|
||||
}
|
||||
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 @@ diff_read(
|
||||
- (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)
|
||||
|
Reference in New Issue
Block a user