]> git.ipfire.org Git - thirdparty/vim.git/commit
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)
commitbc08ceb75572dcac57ef5019f3d0df6e8290c0f9
treefd99bc4d9e1310701da8c48581ebffcabdbf0417
parent334a13bff78aa0ad206bc436885f63e3a0bab399
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.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