Skip to content

Commit bc08ceb

Browse files
ychinchrisbra
authored andcommitted
patch 9.1.1165: diff: regression with multi-file diff blocks
Problem: Vim's diff block merging algorithm when doing a multi-file diff is buggy when two different diff hunks overlap a single existing diff block (after v9.1.0743) Solution: fix a couple bugs in this logic: 1. Fix regression from v9.1.0743 where it's not correctly expanding the 2nd overlap correctly, where it always expands without taking into account that this was always taken care of when the first overlap happened. Instead, we should only grow the 2nd overlap if it overhangs outside the existing diff block, and if we encounter a new overlapping diff block (due to overlap chaining). 2. When we expand a diff block to match the hunk size on the orig side (when handling the first overlap), we expand the same amount of lines in the new side. This is not sound if there exists a second overlap hunk that we haven't processed yet, and that hunk has different number of lines in orig/new. Fix this by doing the corresponding counter adjustment when handling 2nd/3rd/etc overlap by calculating the difference in lines between orig and new side. (Yee Cheng Chin) closes: #16768 Signed-off-by: Yee Cheng Chin <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 334a13b commit bc08ceb

8 files changed

Lines changed: 152 additions & 3 deletions

src/diff.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,22 @@ diff_read(
18261826
else
18271827
{
18281828
// second overlap of new block with existing block
1829-
dp->df_count[idx_new] += hunk->count_new;
1829+
1830+
// if this hunk has different orig/new counts, adjust
1831+
// the diff block size first. When we handled the first hunk we
1832+
// would have expanded it to fit, without knowing that this
1833+
// hunk exists
1834+
int orig_size_in_dp = MIN(hunk->count_orig,
1835+
dp->df_lnum[idx_orig] +
1836+
dp->df_count[idx_orig] - hunk->lnum_orig);
1837+
int size_diff = hunk->count_new - orig_size_in_dp;
1838+
dp->df_count[idx_new] += size_diff;
1839+
1840+
// grow existing block to include the overlap completely
1841+
off = hunk->lnum_new + hunk->count_new
1842+
- (dp->df_lnum[idx_new] + dp->df_count[idx_new]);
1843+
if (off > 0)
1844+
dp->df_count[idx_new] += off;
18301845
if ((dp->df_lnum[idx_new] + dp->df_count[idx_new] - 1)
18311846
> curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count)
18321847
dp->df_count[idx_new] = curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count
@@ -1839,8 +1854,16 @@ diff_read(
18391854
- (dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]);
18401855
if (off < 0)
18411856
{
1842-
// new change ends in existing block, adjust the end
1843-
dp->df_count[idx_new] += -off;
1857+
// new change ends in existing block, adjust the end. We only
1858+
// need to do this once per block or we will over-adjust.
1859+
if (notset || dp != dpl)
1860+
{
1861+
// adjusting by 'off' here is only correct if
1862+
// there is not another hunk in this block. we
1863+
// adjust for this when we encounter a second
1864+
// overlap later.
1865+
dp->df_count[idx_new] += -off;
1866+
}
18441867
if ((dp->df_lnum[idx_new] + dp->df_count[idx_new] - 1)
18451868
> curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count)
18461869
dp->df_count[idx_new] = curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @19||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18
2+
| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|w+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|1+2#0000000#ff404010| +0&#ffd7ff255@20
3+
| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|x+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@20
4+
| +0#0000e05#a8a8a8255@1|c+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|y+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@20
5+
| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@22||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|z+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|2+2#0000000#ff404010| +0&#ffd7ff255@20
6+
| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @19||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18
7+
|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
8+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
9+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
10+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
11+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
12+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
13+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
14+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
15+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
16+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
17+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
18+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
19+
|X+3#0000000&|d|i|f|i|l|e|1| @4|1|,|1| @5|A|l@1| |X+1&&|d|i|f|i|l|e|2| @3|1|,|1| @5|A|l@1| |X|d|i|f|i|l|e|3| @3|1|,|1| @5|A|l@1
20+
|:+0&&> @73
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @19||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18
2+
| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|w+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|1+2#0000000#ff404010| +0&#ffd7ff255@20
3+
| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|x+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@20
4+
| +0#0000e05#a8a8a8255@1|c+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|y+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@20
5+
| +0#0000e05#a8a8a8255@1|d+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|z+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|2+2#0000000#ff404010| +0&#ffd7ff255@20
6+
| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@22||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|u+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|d+2#0000000#ff404010| +0&#ffd7ff255@20
7+
| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @19||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18
8+
|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
9+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
10+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
11+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
12+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
13+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
14+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
15+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
16+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
17+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
18+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
19+
|X+3#0000000&|d|i|f|i|l|e|1| @4|1|,|1| @5|A|l@1| |X+1&&|d|i|f|i|l|e|2| @3|1|,|1| @5|A|l@1| |X|d|i|f|i|l|e|3| @3|1|,|1| @5|A|l@1
20+
|:+0&&> @73
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @19||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18
2+
| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|w+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|1+2#0000000#ff404010| +0&#ffd7ff255@20
3+
| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|x+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@20
4+
| +0#0000e05#a8a8a8255@1|c+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|y+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|2+2#0000000#ff404010| +0&#ffd7ff255@20
5+
| +0#0000e05#a8a8a8255@1|d+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|z+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|3+2#0000000#ff404010| +0&#ffd7ff255@20
6+
| +0#0000e05#a8a8a8255@1|e+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|e+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|d+2#0000000#ff404010| +0&#ffd7ff255@20
7+
| +0#0000e05#a8a8a8255@1|f+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|u+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|4+2#0000000#ff404010| +0&#ffd7ff255@20
8+
| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@22||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|f+0#0000000#5fd7ff255| @20
9+
| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @19||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18
10+
|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
11+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
12+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
13+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
14+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
15+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
16+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
17+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
18+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
19+
|X+3#0000000&|d|i|f|i|l|e|1| @4|1|,|1| @5|A|l@1| |X+1&&|d|i|f|i|l|e|2| @3|1|,|1| @5|A|l@1| |X|d|i|f|i|l|e|3| @3|1|,|1| @5|A|l@1
20+
|:+0&&> @73
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @19||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18
2+
| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|x+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|1+2#0000000#ff404010| +0&#ffd7ff255@20
3+
| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|y+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@20
4+
| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @19||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18
5+
|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
6+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
7+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
8+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
9+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
10+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
11+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
12+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
13+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
14+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
15+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
16+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
17+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
18+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
19+
|X+3#0000000&|d|i|f|i|l|e|1| @4|1|,|1| @5|A|l@1| |X+1&&|d|i|f|i|l|e|2| @3|1|,|1| @5|A|l@1| |X|d|i|f|i|l|e|3| @3|1|,|1| @5|A|l@1
20+
|:+0&&> @73
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @19||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18||+1&&| +0#0000e05#a8a8a8255@1|f+0#0000000#ffffff0|o@1| @18
2+
| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|w+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|1+2#0000000#ff404010| +0&#ffd7ff255@20
3+
| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|x+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@20
4+
| +0#0000e05#a8a8a8255@1|c+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|y+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@20
5+
| +0#0000e05#a8a8a8255@1|d+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|z+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|3+2#0000000#ff404010| +0&#ffd7ff255@20
6+
| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@22||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|u+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|4+2#0000000#ff404010| +0&#ffd7ff255@20
7+
| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@22||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|d+0#0000000#5fd7ff255| @20
8+
| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @19||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18||+1&&| +0#0000e05#a8a8a8255@1|b+0#0000000#ffffff0|a|r| @18
9+
|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
10+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
11+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
12+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
13+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
14+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
15+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
16+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
17+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
18+
|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
19+
|X+3#0000000&|d|i|f|i|l|e|1| @4|1|,|1| @5|A|l@1| |X+1&&|d|i|f|i|l|e|2| @3|1|,|1| @5|A|l@1| |X|d|i|f|i|l|e|3| @3|1|,|1| @5|A|l@1
20+
|:+0&&> @73

src/testdir/test_diffmode.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,30 @@ func Test_diff_overlapped_diff_blocks_will_be_merged()
22962296
call WriteDiffFiles3(buf, ["a", "b", "c"], ["d", "e"], ["b"])
22972297
call VerifyBoth(buf, "Test_diff_overlapped_3.39", "")
22982298

2299+
" File 3 overlaps twice, 2nd overlap completely within the existing block.
2300+
call WriteDiffFiles3(buf, ["foo", "a", "b", "c", "bar"], ["foo", "w", "x", "y", "z", "bar"], ["foo", "1", "a", "b", "2", "bar"])
2301+
call VerifyBoth(buf, "Test_diff_overlapped_3.40", "")
2302+
2303+
" File 3 overlaps twice, 2nd overlap extends beyond existing block on new
2304+
" side. Make sure we don't over-extend the range and hit 'bar'.
2305+
call WriteDiffFiles3(buf, ["foo", "a", "b", "c", "d", "bar"], ["foo", "w", "x", "y", "z", "u", "bar"], ["foo", "1", "a", "b", "2", "d", "bar"])
2306+
call VerifyBoth(buf, "Test_diff_overlapped_3.41", "")
2307+
2308+
" Chained overlaps. File 3's 2nd overlap spans two diff blocks and is longer
2309+
" than the 2nd one.
2310+
call WriteDiffFiles3(buf, ["foo", "a", "b", "c", "d", "e", "f", "bar"], ["foo", "w", "x", "y", "z", "e", "u", "bar"], ["foo", "1", "b", "2", "3", "d", "4", "f", "bar"])
2311+
call VerifyBoth(buf, "Test_diff_overlapped_3.42", "")
2312+
2313+
" File 3 has 2 overlaps. An add and a delete. First overlap's expansion hits
2314+
" the 2nd one. Make sure we adjust the diff block to have fewer lines.
2315+
call WriteDiffFiles3(buf, ["foo", "a", "b", "bar"], ["foo", "x", "y", "bar"], ["foo", "1", "a", "bar"])
2316+
call VerifyBoth(buf, "Test_diff_overlapped_3.43", "")
2317+
2318+
" File 3 has 2 overlaps. An add and another add. First overlap's expansion hits
2319+
" the 2nd one. Make sure we adjust the diff block to have more lines.
2320+
call WriteDiffFiles3(buf, ["foo", "a", "b", "c", "d", "bar"], ["foo", "w", "x", "y", "z", "u", "bar"], ["foo", "1", "a", "b", "3", "4", "d", "bar"])
2321+
call VerifyBoth(buf, "Test_diff_overlapped_3.44", "")
2322+
22992323
call StopVimInTerminal(buf)
23002324
endfunc
23012325

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1165,
707709
/**/
708710
1164,
709711
/**/

0 commit comments

Comments
 (0)