aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/diff_spec.lua82
-rw-r--r--test/old/testdir/test_diffmode.vim24
2 files changed, 106 insertions, 0 deletions
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index dae373297a..e0d88771d3 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -2064,6 +2064,88 @@ it('diff mode overlapped diff blocks will be merged', function()
{2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
|
]])
+
+ -- File 3 overlaps twice, 2nd overlap completely within the existing block.
+ WriteDiffFiles3('foo\na\nb\nc\nbar', 'foo\nw\nx\ny\nz\nbar', 'foo\n1\na\nb\n2\nbar')
+ screen:expect([[
+ {7: }foo │{7: }foo │{7: }^foo |
+ {7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }|
+ {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:a}{4: }|
+ {7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:b}{4: }|
+ {7: }{23:---------}│{7: }{27:z}{4: }│{7: }{27:2}{4: }|
+ {7: }bar │{7: }bar │{7: }bar |
+ {1:~ }│{1:~ }│{1:~ }|*12
+ {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
+ |
+ ]])
+
+ -- 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'.
+ WriteDiffFiles3('foo\na\nb\nc\nd\nbar', 'foo\nw\nx\ny\nz\nu\nbar', 'foo\n1\na\nb\n2\nd\nbar')
+ screen:expect([[
+ {7: }foo │{7: }foo │{7: }^foo |
+ {7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }|
+ {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:a}{4: }|
+ {7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:b}{4: }|
+ {7: }{27:d}{4: }│{7: }{27:z}{4: }│{7: }{27:2}{4: }|
+ {7: }{23:---------}│{7: }{27:u}{4: }│{7: }{27:d}{4: }|
+ {7: }bar │{7: }bar │{7: }bar |
+ {1:~ }│{1:~ }│{1:~ }|*11
+ {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
+ |
+ ]])
+
+ -- Chained overlaps. File 3's 2nd overlap spans two diff blocks and is longer
+ -- than the 2nd one.
+ WriteDiffFiles3(
+ 'foo\na\nb\nc\nd\ne\nf\nbar',
+ 'foo\nw\nx\ny\nz\ne\nu\nbar',
+ 'foo\n1\nb\n2\n3\nd\n4\nf\nbar'
+ )
+ screen:expect([[
+ {7: }foo │{7: }foo │{7: }^foo |
+ {7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }|
+ {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:b}{4: }|
+ {7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:2}{4: }|
+ {7: }{27:d}{4: }│{7: }{27:z}{4: }│{7: }{27:3}{4: }|
+ {7: }{27:e}{4: }│{7: }{27:e}{4: }│{7: }{27:d}{4: }|
+ {7: }{27:f}{4: }│{7: }{27:u}{4: }│{7: }{27:4}{4: }|
+ {7: }{23:---------}│{7: }{23:---------}│{7: }{22:f }|
+ {7: }bar │{7: }bar │{7: }bar |
+ {1:~ }│{1:~ }│{1:~ }|*9
+ {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
+ |
+ ]])
+
+ -- 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.
+ WriteDiffFiles3('foo\na\nb\nbar', 'foo\nx\ny\nbar', 'foo\n1\na\nbar')
+ screen:expect([[
+ {7: }foo │{7: }foo │{7: }^foo |
+ {7: }{27:a}{4: }│{7: }{27:x}{4: }│{7: }{27:1}{4: }|
+ {7: }{27:b}{4: }│{7: }{27:y}{4: }│{7: }{27:a}{4: }|
+ {7: }bar │{7: }bar │{7: }bar |
+ {1:~ }│{1:~ }│{1:~ }|*14
+ {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
+ |
+ ]])
+
+ -- 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.
+ WriteDiffFiles3('foo\na\nb\nc\nd\nbar', 'foo\nw\nx\ny\nz\nu\nbar', 'foo\n1\na\nb\n3\n4\nd\nbar')
+ screen:expect([[
+ {7: }foo │{7: }foo │{7: }^foo |
+ {7: }{27:a}{4: }│{7: }{27:w}{4: }│{7: }{27:1}{4: }|
+ {7: }{27:b}{4: }│{7: }{27:x}{4: }│{7: }{27:a}{4: }|
+ {7: }{27:c}{4: }│{7: }{27:y}{4: }│{7: }{27:b}{4: }|
+ {7: }{27:d}{4: }│{7: }{27:z}{4: }│{7: }{27:3}{4: }|
+ {7: }{23:---------}│{7: }{27:u}{4: }│{7: }{27:4}{4: }|
+ {7: }{23:---------}│{7: }{23:---------}│{7: }{22:d }|
+ {7: }bar │{7: }bar │{7: }bar |
+ {1:~ }│{1:~ }│{1:~ }|*10
+ {2:Xdifile1 Xdifile2 }{3:Xdifile3 }|
+ |
+ ]])
end)
-- oldtest: Test_diff_topline_noscroll()
diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim
index ab64658bd0..0d20085360 100644
--- a/test/old/testdir/test_diffmode.vim
+++ b/test/old/testdir/test_diffmode.vim
@@ -2045,6 +2045,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