patch 9.1.1165: diff: regression with multi-file diff blocks

Commit: 
https://github.com/vim/vim/commit/bc08ceb75572dcac57ef5019f3d0df6e8290c0f9
Author: Yee Cheng Chin <ychin....@gmail.com>
Date:   Sun Mar 2 22:05:37 2025 +0100

    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 <ychin....@gmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/diff.c b/src/diff.c
index d7433349a..6e5097e4a 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -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
index 000000000..4307cfb1c
--- /dev/null
+++ b/src/testdir/dumps/Test_diff_overlapped_3.40.dump
@@ -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
index 000000000..658c09f2a
--- /dev/null
+++ b/src/testdir/dumps/Test_diff_overlapped_3.41.dump
@@ -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
index 000000000..2e9357027
--- /dev/null
+++ b/src/testdir/dumps/Test_diff_overlapped_3.42.dump
@@ -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
index 000000000..f9f75e84e
--- /dev/null
+++ b/src/testdir/dumps/Test_diff_overlapped_3.43.dump
@@ -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
index 000000000..64780a497
--- /dev/null
+++ b/src/testdir/dumps/Test_diff_overlapped_3.44.dump
@@ -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
diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index 36d3d9ba6..b62266bb8 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
@@ -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
 
diff --git a/src/version.c b/src/version.c
index 6fd80d6b1..48d11c4b3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1165,
 /**/
     1164,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1toqeN-004xO2-Pz%40256bit.org.

Raspunde prin e-mail lui