]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1165: diff: regression with multi-file diff blocks v9.1.1165
authorYee Cheng Chin <ychin.git@gmail.com>
Sun, 2 Mar 2025 21:05:37 +0000 (22:05 +0100)
committerChristian Brabandt <cb@256bit.org>
Sun, 2 Mar 2025 21:05:37 +0000 (22:05 +0100)
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 <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/diff.c
src/testdir/dumps/Test_diff_overlapped_3.40.dump [new file with mode: 0644]
src/testdir/dumps/Test_diff_overlapped_3.41.dump [new file with mode: 0644]
src/testdir/dumps/Test_diff_overlapped_3.42.dump [new file with mode: 0644]
src/testdir/dumps/Test_diff_overlapped_3.43.dump [new file with mode: 0644]
src/testdir/dumps/Test_diff_overlapped_3.44.dump [new file with mode: 0644]
src/testdir/test_diffmode.vim
src/version.c

index d7433349a46fe3311bba5bd0d1bcaa6e462fb3c0..6e5097e4a8cc1307dbb71b6bb5cde55d9479c087 100644 (file)
@@ -1826,7 +1826,22 @@ diff_read(
            else
            {
                // second overlap of new block with existing block
-               dp->df_count[idx_new] += hunk->count_new;
+
+               // if this hunk has different orig/new counts, adjust
+               // the diff block size first. When we handled the first hunk we
+               // would have expanded it to fit, without knowing that this
+               // hunk exists
+               int orig_size_in_dp = MIN(hunk->count_orig,
+                       dp->df_lnum[idx_orig] +
+                       dp->df_count[idx_orig] - hunk->lnum_orig);
+               int size_diff = hunk->count_new - orig_size_in_dp;
+               dp->df_count[idx_new] += size_diff;
+
+               // grow existing block to include the overlap completely
+               off = hunk->lnum_new + hunk->count_new
+                   - (dp->df_lnum[idx_new] + dp->df_count[idx_new]);
+               if (off > 0)
+                   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
@@ -1839,8 +1854,16 @@ diff_read(
                         - (dpl->df_lnum[idx_orig] + dpl->df_count[idx_orig]);
            if (off < 0)
            {
-               // new change ends in existing block, adjust the end
-               dp->df_count[idx_new] += -off;
+               // new change ends in existing block, adjust the end. We only
+               // need to do this once per block or we will over-adjust.
+               if (notset || dp != dpl)
+               {
+                   // adjusting by 'off' here is only correct if
+                   // there is not another hunk in this block. we
+                   // adjust for this when we encounter a second
+                   // overlap later.
+                   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
diff --git a/src/testdir/dumps/Test_diff_overlapped_3.40.dump b/src/testdir/dumps/Test_diff_overlapped_3.40.dump
new file mode 100644 (file)
index 0000000..4307cfb
--- /dev/null
@@ -0,0 +1,20 @@
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|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
+|:+0&&> @73
diff --git a/src/testdir/dumps/Test_diff_overlapped_3.41.dump b/src/testdir/dumps/Test_diff_overlapped_3.41.dump
new file mode 100644 (file)
index 0000000..658c09f
--- /dev/null
@@ -0,0 +1,20 @@
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|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
+|:+0&&> @73
diff --git a/src/testdir/dumps/Test_diff_overlapped_3.42.dump b/src/testdir/dumps/Test_diff_overlapped_3.42.dump
new file mode 100644 (file)
index 0000000..2e93570
--- /dev/null
@@ -0,0 +1,20 @@
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|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
+|:+0&&> @73
diff --git a/src/testdir/dumps/Test_diff_overlapped_3.43.dump b/src/testdir/dumps/Test_diff_overlapped_3.43.dump
new file mode 100644 (file)
index 0000000..f9f75e8
--- /dev/null
@@ -0,0 +1,20 @@
+| +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
+| +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
+| +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
+| +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
+|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|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
+|:+0&&> @73
diff --git a/src/testdir/dumps/Test_diff_overlapped_3.44.dump b/src/testdir/dumps/Test_diff_overlapped_3.44.dump
new file mode 100644 (file)
index 0000000..64780a4
--- /dev/null
@@ -0,0 +1,20 @@
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+| +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
+|~+0#4040ff13&| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22
+|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
+|:+0&&> @73
index 36d3d9ba6539eb7a43ca19b1b6d0f12bb1cd1418..b62266bb8aa65206b760c835e1b7cf4c11a5f74b 100644 (file)
@@ -2296,6 +2296,30 @@ func Test_diff_overlapped_diff_blocks_will_be_merged()
   call WriteDiffFiles3(buf, ["a", "b", "c"], ["d", "e"], ["b"])
   call VerifyBoth(buf, "Test_diff_overlapped_3.39", "")
 
+  " File 3 overlaps twice, 2nd overlap completely within the existing block.
+  call WriteDiffFiles3(buf, ["foo", "a", "b", "c", "bar"], ["foo", "w", "x", "y", "z", "bar"], ["foo", "1", "a", "b", "2", "bar"])
+  call VerifyBoth(buf, "Test_diff_overlapped_3.40", "")
+
+  " File 3 overlaps twice, 2nd overlap extends beyond existing block on new
+  " side. Make sure we don't over-extend the range and hit 'bar'.
+  call WriteDiffFiles3(buf, ["foo", "a", "b", "c", "d", "bar"], ["foo", "w", "x", "y", "z", "u", "bar"], ["foo", "1", "a", "b", "2", "d", "bar"])
+  call VerifyBoth(buf, "Test_diff_overlapped_3.41", "")
+
+  " Chained overlaps. File 3's 2nd overlap spans two diff blocks and is longer
+  " than the 2nd one.
+  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"])
+  call VerifyBoth(buf, "Test_diff_overlapped_3.42", "")
+
+  " File 3 has 2 overlaps. An add and a delete. First overlap's expansion hits
+  " the 2nd one. Make sure we adjust the diff block to have fewer lines.
+  call WriteDiffFiles3(buf, ["foo", "a", "b", "bar"], ["foo", "x", "y", "bar"], ["foo", "1", "a", "bar"])
+  call VerifyBoth(buf, "Test_diff_overlapped_3.43", "")
+
+  " File 3 has 2 overlaps. An add and another add. First overlap's expansion hits
+  " the 2nd one. Make sure we adjust the diff block to have more lines.
+  call WriteDiffFiles3(buf, ["foo", "a", "b", "c", "d", "bar"], ["foo", "w", "x", "y", "z", "u", "bar"], ["foo", "1", "a", "b", "3", "4", "d", "bar"])
+  call VerifyBoth(buf, "Test_diff_overlapped_3.44", "")
+
   call StopVimInTerminal(buf)
 endfunc
 
index 6fd80d6b125d9d72e41c51637bdeaa4d7a786551..48d11c4b39c9bb33cd2270f8511c4ffee97017ff 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1165,
 /**/
     1164,
 /**/