patch 9.1.1018: v9.1.0743 causes regression with diff mode
Problem: v9.1.0743 causes regression with diff mode
Solution: Fix the regression with overlapping regions
closes: #16454
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 971ef65..7e56641 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -1824,8 +1824,14 @@
dp->df_count[idx_new] = hunk->count_new - off;
}
else
+ {
// second overlap of new block with existing block
dp->df_count[idx_new] += hunk->count_new;
+ if ((dp->df_lnum[idx_new] + dp->df_count[idx_new] - 1)
+ > curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count)
+ dp->df_count[idx_new] = curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count
+ - dp->df_lnum[idx_new] + 1;
+ }
// 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.
@@ -1835,6 +1841,10 @@
{
// new change ends in existing block, adjust the end
dp->df_count[idx_new] += -off;
+ if ((dp->df_lnum[idx_new] + dp->df_count[idx_new] - 1)
+ > curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count)
+ dp->df_count[idx_new] = curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count
+ - dp->df_lnum[idx_new] + 1;
off = 0;
}
for (i = idx_orig; i < idx_new; ++i)