aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-27 09:24:26 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-03-28 14:45:01 +0800
commit2331c52affe64070ad59c0ef63ddcc8f7ca41781 (patch)
treea2438a9e9cecad08f85890c959a02523a1861260 /test
parentae98d0a560b08d901ee9aae85df634de0ae3fe0a (diff)
downloadrneovim-2331c52affe64070ad59c0ef63ddcc8f7ca41781.tar.gz
rneovim-2331c52affe64070ad59c0ef63ddcc8f7ca41781.tar.bz2
rneovim-2331c52affe64070ad59c0ef63ddcc8f7ca41781.zip
vim-patch:9.1.1243: diff mode is lacking for changes within lines
Problem: Diff mode's inline highlighting is lackluster. It only performs a line-by-line comparison, and calculates a single shortest range within a line that could encompass all the changes. In lines with multiple changes, or those that span multiple lines, this approach tends to end up highlighting much more than necessary. Solution: Implement new inline highlighting modes by doing per-character or per-word diff within the diff block, and highlight only the relevant parts, add "inline:simple" to the defaults (which is the old behaviour) This change introduces a new diffopt option "inline:<type>". Setting to "none" will disable all inline highlighting, "simple" (the default) will use the old behavior, "char" / "word" will perform a character/word-wise diff of the texts within each diff block and only highlight the differences. The new char/word inline diff only use the internal xdiff, and will respect diff options such as algorithm choice, icase, and misc iwhite options. indent-heuristics is always on to perform better sliding. For character highlight, a post-process of the diff results is first applied before we show the highlight. This is because a naive diff will create a result with a lot of small diff chunks and gaps, due to the repetitive nature of individual characters. The post-process is a heuristic-based refinement that attempts to merge adjacent diff blocks if they are separated by a short gap (1-3 characters), and can be further tuned in the future for better results. This process results in more characters than necessary being highlighted but overall less visual noise. For word highlight, always use first buffer's iskeyword definition. Otherwise if each buffer has different iskeyword settings we would not be able to group words properly. The char/word diffing is always per-diff block, not per line, meaning that changes that span multiple lines will show up correctly. Added/removed newlines are not shown by default, but if the user has 'list' set (with "eol" listchar defined), the eol character will be be highlighted correctly for the specific newline characters. Also, add a new "DiffTextAdd" highlight group linked to "DiffText" by default. It allows color schemes to use different colors for texts that have been added within a line versus modified. This doesn't interact with linematch perfectly currently. The linematch feature splits up diff blocks into multiple smaller blocks for better visual matching, which makes inline highlight less useful especially for multi-line change (e.g. a line is broken into two lines). This could be addressed in the future. As a side change, this also removes the bounds checking introduced to diff_read() as they were added to mask existing logic bugs that were properly fixed in vim/vim#16768. closes: vim/vim#16881 https://github.com/vim/vim/commit/9943d4790e42721a6777da9e12637aa595ba4965 Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/functional/ui/cmdline_spec.lua2
-rw-r--r--test/functional/ui/cursor_spec.lua4
-rw-r--r--test/functional/ui/diff_spec.lua534
-rw-r--r--test/functional/ui/messages_spec.lua8
-rw-r--r--test/old/testdir/gen_opt_test.vim6
-rw-r--r--test/old/testdir/setup.vim2
-rw-r--r--test/old/testdir/test_diffmode.vim203
-rw-r--r--test/old/testdir/test_options.vim5
8 files changed, 747 insertions, 17 deletions
diff --git a/test/functional/ui/cmdline_spec.lua b/test/functional/ui/cmdline_spec.lua
index 99af9f9f73..59c8be3d5e 100644
--- a/test/functional/ui/cmdline_spec.lua
+++ b/test/functional/ui/cmdline_spec.lua
@@ -858,7 +858,7 @@ local function test_cmdline(linegrid)
cmdline = {
{
content = { { '' } },
- hl_id = 242,
+ hl_id = 243,
pos = 0,
prompt = 'Prompt:',
},
diff --git a/test/functional/ui/cursor_spec.lua b/test/functional/ui/cursor_spec.lua
index ff304db54c..087ae79eb1 100644
--- a/test/functional/ui/cursor_spec.lua
+++ b/test/functional/ui/cursor_spec.lua
@@ -258,11 +258,11 @@ describe('ui/cursor', function()
end
end
if m.hl_id then
- m.hl_id = 65
+ m.hl_id = 66
m.attr = { background = Screen.colors.DarkGray }
end
if m.id_lm then
- m.id_lm = 72
+ m.id_lm = 73
m.attr_lm = {}
end
end
diff --git a/test/functional/ui/diff_spec.lua b/test/functional/ui/diff_spec.lua
index e0d88771d3..223622eb6b 100644
--- a/test/functional/ui/diff_spec.lua
+++ b/test/functional/ui/diff_spec.lua
@@ -1555,7 +1555,6 @@ it('diff mode overlapped diff blocks will be merged', function()
local screen = Screen.new(35, 20)
command('set winwidth=10 diffopt=filler,internal')
-
command('args Xdifile1 Xdifile2 | vert all | windo diffthis')
WriteDiffFiles('a\nb', 'x\nx')
@@ -2252,3 +2251,536 @@ it('diff mode does not scroll with line("w0")', function()
9 |
]])
end)
+
+-- oldtest: Test_diff_inline()
+it('diff mode inline highlighting', function()
+ write_file('Xdifile1', '')
+ write_file('Xdifile2', '')
+ finally(function()
+ os.remove('Xdifile1')
+ os.remove('Xdifile2')
+ end)
+
+ local screen = Screen.new(37, 20)
+ screen:add_extra_attr_ids({
+ [100] = { background = Screen.colors.Blue1 },
+ [101] = { bold = true, background = Screen.colors.Red, foreground = Screen.colors.Blue1 },
+ [102] = { background = Screen.colors.LightMagenta, foreground = Screen.colors.Blue1 },
+ [103] = { bold = true, background = Screen.colors.Blue1, foreground = Screen.colors.Blue1 },
+ [104] = { bold = true, background = Screen.colors.LightBlue, foreground = Screen.colors.Blue1 },
+ })
+ command('set winwidth=10')
+ command('args Xdifile1 Xdifile2 | vert all | windo diffthis | 1wincmd w')
+
+ WriteDiffFiles('abcdef ghi jk n\nx\ny', 'aBcef gHi lm n\ny\nz')
+ command('set diffopt=internal,filler')
+ local s1 = [[
+ {7: }{4:^a}{27:bcdef ghi jk}{4: n }│{7: }{4:a}{27:Bcef gHi lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]]
+ screen:expect(s1)
+ command('set diffopt=internal,filler diffopt+=inline:none')
+ local s2 = [[
+ {7: }{4:^abcdef ghi jk n }│{7: }{4:aBcef gHi lm n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]]
+ screen:expect(s2)
+
+ -- inline:simple is the same as default
+ command('set diffopt=internal,filler diffopt+=inline:simple')
+ screen:expect(s1)
+
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ local s3 = [[
+ {7: }{4:^a}{27:b}{4:c}{27:d}{4:ef g}{27:h}{4:i }{27:jk}{4: n }│{7: }{4:a}{27:B}{4:cef g}{27:H}{4:i }{27:lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]]
+ screen:expect(s3)
+
+ command('set diffopt=internal,filler diffopt+=inline:word')
+ screen:expect([[
+ {7: }{27:^abcdef}{4: }{27:ghi}{4: }{27:jk}{4: n }│{7: }{27:aBcef}{4: }{27:gHi}{4: }{27:lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ -- multiple inline values will the last one
+ command('set diffopt=internal,filler diffopt+=inline:none,inline:char,inline:simple')
+ screen:expect(s1)
+ command('set diffopt=internal,filler diffopt+=inline:simple,inline:word,inline:none')
+ screen:expect(s2)
+ command('set diffopt=internal,filler diffopt+=inline:simple,inline:word,inline:char')
+ screen:expect(s3)
+
+ -- DiffTextAdd highlight
+ command('hi DiffTextAdd guibg=blue')
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ screen:expect([[
+ {7: }{4:^a}{27:b}{4:c}{100:d}{4:ef g}{27:h}{4:i }{27:jk}{4: n }│{7: }{4:a}{27:B}{4:cef g}{27:H}{4:i }{27:lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ -- Live update in insert mode
+ feed('isometext')
+ screen:expect([[
+ {7: }{27:sometext^abcd}{4:ef g}│{7: }{27:aBc}{4:ef g}{27:H}{4:i }{27:lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 [+] }{2:Xdifile2 }|
+ {5:-- INSERT --} |
+ ]])
+ feed('<Esc>')
+ command('silent! undo')
+
+ -- icase simple scenarios
+ command('set diffopt=internal,filler diffopt+=inline:simple,icase')
+ screen:expect([[
+ {7: }{4:^abc}{27:def ghi jk}{4: n }│{7: }{4:aBc}{27:ef gHi lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,icase')
+ screen:expect([[
+ {7: }{4:^abc}{100:d}{4:ef ghi }{27:jk}{4: n }│{7: }{4:aBcef gHi }{27:lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:word,icase')
+ screen:expect([[
+ {7: }{27:^abcdef}{4: ghi }{27:jk}{4: n }│{7: }{27:aBcef}{4: gHi }{27:lm}{4: n }|
+ {7: }{22:x }│{7: }{23:----------------}|
+ {7: }y │{7: }y |
+ {7: }{23:----------------}│{7: }{22:z }|
+ {1:~ }│{1:~ }|*14
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ screen:try_resize(45, 20)
+ command('wincmd =')
+ -- diff algorithms should affect highlight
+ WriteDiffFiles('apples and oranges', 'oranges and apples')
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ screen:expect([[
+ {7: }{27:^appl}{4:es and }{27:orang}{4:es }│{7: }{27:orang}{4:es and }{27:appl}{4:es }|
+ {1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,algorithm:patience')
+ screen:expect([[
+ {7: }{100:^apples and }{4:oranges }│{7: }{4:oranges}{100: and apples}{4: }|
+ {1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ screen:try_resize(65, 20)
+ command('wincmd =')
+ -- icase: composing chars and Unicode fold case edge cases
+ WriteDiffFiles(
+ '1 - sigma in 6σ and Ὀδυσσεύς\n1 - angstrom in åå\n1 - composing: ii⃗I⃗',
+ '2 - Sigma in 6Σ and ὈΔΥΣΣΕΎΣ\n2 - Angstrom in ÅÅ\n2 - Composing: i⃗I⃗I⃗'
+ )
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ screen:expect([[
+ {7: }{27:^1}{4: - }{27:s}{4:igma in 6}{27:σ}{4: and Ὀ}{27:δυσσεύς}{4: }│{7: }{27:2}{4: - }{27:S}{4:igma in 6}{27:Σ}{4: and Ὀ}{27:ΔΥΣΣΕΎΣ}{4: }|
+ {7: }{27:1}{4: - }{27:a}{4:ngstrom in }{27:åå}{4: }│{7: }{27:2}{4: - }{27:A}{4:ngstrom in }{27:ÅÅ}{4: }|
+ {7: }{27:1}{4: - }{27:c}{4:omposing: }{100:i}{4:i⃗I⃗ }│{7: }{27:2}{4: - }{27:C}{4:omposing: i⃗I⃗}{100:I⃗}{4: }|
+ {1:~ }│{1:~ }|*15
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,icase')
+ screen:expect([[
+ {7: }{27:^1}{4: - sigma in 6σ and Ὀδυσσεύς }│{7: }{27:2}{4: - Sigma in 6Σ and ὈΔΥΣΣΕΎΣ }|
+ {7: }{27:1}{4: - angstrom in åå }│{7: }{27:2}{4: - Angstrom in ÅÅ }|
+ {7: }{27:1}{4: - composing: }{27:i}{4:i⃗I⃗ }│{7: }{27:2}{4: - Composing: }{27:i⃗}{4:I⃗I⃗ }|
+ {1:~ }│{1:~ }|*15
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ screen:try_resize(35, 20)
+ command('wincmd =')
+ -- wide chars
+ WriteDiffFiles('abc😅xde一\nf🚀g', 'abcy😢de\n二f🚀g')
+ command('set diffopt=internal,filler diffopt+=inline:char,icase')
+ screen:expect([[
+ {7: }{4:^abc}{27:😅x}{4:de}{100:一}{4: }│{7: }{4:abc}{27:y😢}{4:de }|
+ {7: }{4:f🚀g }│{7: }{100:二}{4:f🚀g }|
+ {1:~ }│{1:~ }|*16
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ -- NUL char
+ WriteDiffFiles('1\00034\0005\0006', '1234\0005\n6')
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ screen:expect([[
+ {7: }{4:^1}{101:^@}{4:34}{102:^@}{4:5}{101:^@}{4:6 }│{7: }{4:1}{27:2}{4:34}{102:^@}{4:5 }|
+ {7: }{23:---------------}│{7: }{4:6 }|
+ {1:~ }│{1:~ }|*16
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ -- word diff: always use first buffer's iskeyword and ignore others' for consistency
+ WriteDiffFiles('foo+bar test', 'foo+baz test')
+ command('set diffopt=internal,filler diffopt+=inline:word')
+ local sw1 = [[
+ {7: }{4:^foo+}{27:bar}{4: test }│{7: }{4:foo+}{27:baz}{4: test }|
+ {1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]]
+ screen:expect(sw1)
+
+ command('set iskeyword+=+ | diffupdate')
+ screen:expect([[
+ {7: }{27:^foo+bar}{4: test }│{7: }{27:foo+baz}{4: test }|
+ {1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ command('set iskeyword& | wincmd w')
+ command('set iskeyword+=+ | wincmd w | diffupdate')
+ -- Use the previous screen as 2nd buffer's iskeyword does not matter
+ screen:expect(sw1)
+
+ command('windo set iskeyword& | 1wincmd w')
+
+ screen:try_resize(69, 20)
+ command('wincmd =')
+ -- char diff: should slide highlight to whitespace boundary if possible for
+ -- better readability (by using forced indent-heuristics). A wrong result
+ -- would be if the highlight is "Bar, prefix". It should be "prefixBar, "
+ -- instead.
+ WriteDiffFiles('prefixFoo, prefixEnd', 'prefixFoo, prefixBar, prefixEnd')
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ screen:expect([[
+ {7: }{4:^prefixFoo, prefixEnd }│{7: }{4:prefixFoo, }{100:prefixBar, }{4:prefixEnd }|
+ {1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ screen:try_resize(39, 20)
+ command('wincmd =')
+ -- char diff: small gaps between inline diff blocks will be merged during refine step
+ -- - first segment: test that we iteratively merge small gaps after we merged
+ -- adjacent blocks, but only with limited number (set to 4) of iterations.
+ -- - second and third segments: show that we need a large enough adjacent block to
+ -- trigger a merge.
+ -- - fourth segment: small gaps are not merged when adjacent large block is
+ -- on a different line.
+ WriteDiffFiles(
+ 'abcdefghijklmno\nanchor1\n'
+ .. 'abcdefghijklmno\nanchor2\n'
+ .. 'abcdefghijklmno\nanchor3\n'
+ .. 'test\nmultiline',
+ 'a?c?e?g?i?k???o\nanchor1\n'
+ .. 'a??de?????klmno\nanchor2\n'
+ .. 'a??de??????lmno\nanchor3\n'
+ .. 't?s?\n??????i?e'
+ )
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ screen:expect([[
+ {7: }{4:^a}{27:b}{4:c}{27:defghijklmn}{4:o }│{7: }{4:a}{27:?}{4:c}{27:?e?g?i?k???}{4:o }|
+ {7: }anchor1 │{7: }anchor1 |
+ {7: }{4:a}{27:bc}{4:de}{27:fghij}{4:klmno }│{7: }{4:a}{27:??}{4:de}{27:?????}{4:klmno }|
+ {7: }anchor2 │{7: }anchor2 |
+ {7: }{4:a}{27:bcdefghijk}{4:lmno }│{7: }{4:a}{27:??de??????}{4:lmno }|
+ {7: }anchor3 │{7: }anchor3 |
+ {7: }{4:t}{27:e}{4:s}{27:t}{4: }│{7: }{4:t}{27:?}{4:s}{27:?}{4: }|
+ {7: }{27:multilin}{4:e }│{7: }{27:??????i?}{4:e }|
+ {1:~ }│{1:~ }|*10
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ screen:try_resize(49, 20)
+ command('wincmd =')
+ -- Test multi-line blocks and whitespace
+ WriteDiffFiles(
+ 'this is \nsometest text foo\nbaz abc def \none\nword another word\nadditional line',
+ 'this is some test\ntexts\nfoo bar abX Yef \noneword another word'
+ )
+ command('set diffopt=internal,filler diffopt+=inline:char,iwhite')
+ screen:expect([[
+ {7: }{4:^this is }│{7: }{4:this is some}{100: }{4:test }|
+ {7: }{4:sometest text foo }│{7: }{4:text}{100:s}{4: }|
+ {7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }|
+ {7: }{4:one }│{7: }{4:oneword another word }|
+ {7: }{4:word another word }│{7: }{23:----------------------}|
+ {7: }{22:additional line }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:word,iwhite')
+ screen:expect([[
+ {7: }{4:^this is }│{7: }{4:this is }{27:some}{4: }{27:test}{4: }|
+ {7: }{27:sometest}{4: }{27:text}{4: }{27:foo}{4: }│{7: }{27:texts}{4: }|
+ {7: }{27:baz}{4: }{27:abc}{4: }{27:def}{4: }│{7: }{27:foo}{4: }{27:bar}{4: }{27:abX}{4: }{27:Yef}{4: }|
+ {7: }{27:one}{4: }│{7: }{27:oneword}{4: another word }|
+ {7: }{27:word}{4: another word }│{7: }{23:----------------------}|
+ {7: }{22:additional line }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,iwhiteeol')
+ screen:expect([[
+ {7: }{4:^this }{100: }{4:is }│{7: }{4:this is some}{100: }{4:test }|
+ {7: }{4:sometest text foo }│{7: }{4:text}{100:s}{4: }|
+ {7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }|
+ {7: }{4:one }│{7: }{4:oneword another word }|
+ {7: }{4:word another word }│{7: }{23:----------------------}|
+ {7: }{22:additional line }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:word,iwhiteeol')
+ screen:expect([[
+ {7: }{4:^this }{100: }{4:is }│{7: }{4:this is }{27:some}{4: }{27:test}{4: }|
+ {7: }{27:sometest}{4: }{27:text}{4: foo }│{7: }{27:texts}{4: }|
+ {7: }{27:baz}{4: }{27:abc}{4: }{27:def}{4: }│{7: }{4:foo }{27:bar}{4: }{27:abX}{4: }{27:Yef}{4: }|
+ {7: }{27:one}{4: }│{7: }{27:oneword}{4: another word }|
+ {7: }{27:word}{4: another word }│{7: }{23:----------------------}|
+ {7: }{22:additional line }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,iwhiteall')
+ screen:expect([[
+ {7: }{4:^this is }│{7: }{4:this is some test }|
+ {7: }{4:sometest text foo }│{7: }{4:text}{100:s}{4: }|
+ {7: }{4:ba}{27:z}{4: ab}{27:c d}{4:ef }│{7: }{4:foo ba}{27:r}{4: ab}{27:X Y}{4:ef }|
+ {7: }{4:one }│{7: }{4:oneword another word }|
+ {7: }{4:word another word }│{7: }{23:----------------------}|
+ {7: }{22:additional line }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:word,iwhiteall')
+ screen:expect([[
+ {7: }{4:^this is }│{7: }{4:this is }{27:some test}{4: }|
+ {7: }{27:sometest text}{4: foo }│{7: }{27:texts}{4: }|
+ {7: }{27:baz abc def }{4: }│{7: }{4:foo }{27:bar abX Yef }{4: }|
+ {7: }{27:one}{4: }│{7: }{27:oneword}{4: another word }|
+ {7: }{27:word}{4: another word }│{7: }{23:----------------------}|
+ {7: }{22:additional line }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {3:Xdifile1 }{2:Xdifile2 }|
+ |
+ ]])
+
+ -- newline should be highlighted too when 'list' is set
+ command('windo set list listchars=eol:$')
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ screen:expect([[
+ {7: }{4:this }{100: }{4:is }{100: }{103:$}{4: }│{7: }{4:^this is some}{100: }{4:test}{101:$}{4: }|
+ {7: }{4:sometest}{27: }{4:text}{27: }{4:foo}{101:$}{4: }│{7: }{4:text}{27:s}{101:$}{4: }|
+ {7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }{11:$}{4: }│{7: }{4:foo}{27: }{4:ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }{100: }{11:$}{4: }|
+ {7: }{4:one}{103:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }|
+ {7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}|
+ {7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {2:Xdifile1 }{3:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,iwhite')
+ screen:expect([[
+ {7: }{4:this is }{11:$}{4: }│{7: }{4:^this is some}{100: }{4:test}{11:$}{4: }|
+ {7: }{4:sometest text foo}{11:$}{4: }│{7: }{4:text}{100:s}{11:$}{4: }|
+ {7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }{11:$}{4: }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }{11:$}{4: }|
+ {7: }{4:one}{103:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }|
+ {7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}|
+ {7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {2:Xdifile1 }{3:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,iwhiteeol')
+ screen:expect([[
+ {7: }{4:this }{100: }{4:is }{11:$}{4: }│{7: }{4:^this is some}{100: }{4:test}{11:$}{4: }|
+ {7: }{4:sometest text foo}{11:$}{4: }│{7: }{4:text}{100:s}{11:$}{4: }|
+ {7: }{4:ba}{27:z}{4: ab}{27:c}{4: }{27:d}{4:ef }{11:$}{4: }│{7: }{4:foo ba}{27:r}{4: ab}{27:X}{4: }{27:Y}{4:ef }{11:$}{4: }|
+ {7: }{4:one}{103:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }|
+ {7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}|
+ {7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {2:Xdifile1 }{3:Xdifile2 }|
+ |
+ ]])
+ command('set diffopt=internal,filler diffopt+=inline:char,iwhiteall')
+ screen:expect([[
+ {7: }{4:this is }{11:$}{4: }│{7: }{4:^this is some test}{11:$}{4: }|
+ {7: }{4:sometest text foo}{11:$}{4: }│{7: }{4:text}{100:s}{11:$}{4: }|
+ {7: }{4:ba}{27:z}{4: ab}{27:c d}{4:ef }{11:$}{4: }│{7: }{4:foo ba}{27:r}{4: ab}{27:X Y}{4:ef }{11:$}{4: }|
+ {7: }{4:one}{11:$}{4: }│{7: }{4:oneword another word}{11:$}{4: }|
+ {7: }{4:word another word}{11:$}{4: }│{7: }{23:----------------------}|
+ {7: }{22:additional line}{104:$}{22: }│{7: }{23:----------------------}|
+ {1:~ }│{1:~ }|*12
+ {2:Xdifile1 }{3:Xdifile2 }|
+ |
+ ]])
+ command('windo set nolist')
+end)
+
+-- oldtest: Test_diff_inline_multibuffer()
+it('diff mode inline highlighting with 3 buffers', function()
+ write_file('Xdifile1', '')
+ write_file('Xdifile2', '')
+ write_file('Xdifile3', '')
+ finally(function()
+ os.remove('Xdifile1')
+ os.remove('Xdifile2')
+ os.remove('Xdifile3')
+ end)
+
+ local screen = Screen.new(75, 20)
+ screen:add_extra_attr_ids({
+ [100] = { background = Screen.colors.Blue1 },
+ })
+ command('args Xdifile1 Xdifile2 Xdifile3 | vert all | windo diffthis | 1wincmd w')
+ command('wincmd =')
+ command('hi DiffTextAdd guibg=Blue')
+
+ WriteDiffFiles3(
+ 'That is buffer1.\nanchor\nSome random text\nanchor',
+ 'This is buffer2.\nanchor\nSome text\nanchor\nbuffer2/3',
+ 'This is buffer3. Last.\nanchor\nSome more\ntext here.\nanchor\nonly in buffer2/3\nnot in buffer1'
+ )
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ local s1 = [[
+ {7: }{4:^Th}{27:at}{4: is buffer}{27:1}{4:. }│{7: }{4:Th}{27:is}{4: is buffer}{27:2}{4:. }│{7: }{4:Th}{27:is}{4: is buffer}{27:3. Last}{4:.}|
+ {7: }anchor │{7: }anchor │{7: }anchor |
+ {7: }{4:Some }{27:random }{4:text }│{7: }{4:Some text }│{7: }{4:Some }{27:more}{4: }|
+ {7: }{23:-----------------------}│{7: }{23:----------------------}│{7: }{4:text}{100: here.}{4: }|
+ {7: }anchor │{7: }anchor │{7: }anchor |
+ {7: }{23:-----------------------}│{7: }{4:buffer2/3 }│{7: }{100:only in }{4:buffer2/3 }|
+ {7: }{23:-----------------------}│{7: }{23:----------------------}│{7: }{22:not in buffer1 }|
+ {1:~ }│{1:~ }│{1:~ }|*11
+ {3:Xdifile1 }{2:Xdifile2 Xdifile3 }|
+ |
+ ]]
+ screen:expect(s1)
+
+ -- Close one of the buffers and make sure it updates correctly
+ command('diffoff')
+ screen:expect([[
+ ^That is buffer1. │{7: }{4:This is buffer}{27:2}{4:. }│{7: }{4:This is buffer}{27:3. Last}{4:.}|
+ anchor │{7: }anchor │{7: }anchor |
+ Some random text │{7: }{4:Some text }│{7: }{4:Some }{100:more}{4: }|
+ anchor │{7: }{23:----------------------}│{7: }{4:text}{100: here.}{4: }|
+ {1:~ }│{7: }anchor │{7: }anchor |
+ {1:~ }│{7: }{4:buffer2/3 }│{7: }{100:only in }{4:buffer2/3 }|
+ {1:~ }│{7: }{23:----------------------}│{7: }{22:not in buffer1 }|
+ {1:~ }│{1:~ }│{1:~ }|*11
+ {3:Xdifile1 }{2:Xdifile2 Xdifile3 }|
+ |
+ ]])
+
+ -- Update text in the non-diff buffer and nothing should be changed
+ feed('isometext')
+ screen:expect([[
+ sometext^That is buffer1. │{7: }{4:This is buffer}{27:2}{4:. }│{7: }{4:This is buffer}{27:3. Last}{4:.}|
+ anchor │{7: }anchor │{7: }anchor |
+ Some random text │{7: }{4:Some text }│{7: }{4:Some }{100:more}{4: }|
+ anchor │{7: }{23:----------------------}│{7: }{4:text}{100: here.}{4: }|
+ {1:~ }│{7: }anchor │{7: }anchor |
+ {1:~ }│{7: }{4:buffer2/3 }│{7: }{100:only in }{4:buffer2/3 }|
+ {1:~ }│{7: }{23:----------------------}│{7: }{22:not in buffer1 }|
+ {1:~ }│{1:~ }│{1:~ }|*11
+ {3:Xdifile1 [+] }{2:Xdifile2 Xdifile3 }|
+ {5:-- INSERT --} |
+ ]])
+ feed('<Esc>')
+ command('silent! undo')
+
+ command('diffthis')
+ screen:expect(s1)
+
+ -- Test that removing first buffer from diff will in turn use the next
+ -- earliest buffer's iskeyword during word diff.
+ WriteDiffFiles3('This+is=a-setence', 'This+is=another-setence', 'That+is=a-setence')
+ command('set iskeyword+=+ | 2wincmd w | set iskeyword+=- | 1wincmd w')
+ command('set diffopt=internal,filler diffopt+=inline:word')
+ local s4 = [[
+ {7: }{27:^This+is}{4:=}{27:a}{4:-setence }│{7: }{27:This+is}{4:=}{27:another}{4:-setenc}│{7: }{27:That+is}{4:=}{27:a}{4:-setence }|
+ {1:~ }│{1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 Xdifile3 }|
+ |
+ ]]
+ screen:expect(s4)
+ command('diffoff')
+ screen:expect([[
+ ^This+is=a-setence │{7: }{27:This}{4:+is=}{27:another-setenc}│{7: }{27:That}{4:+is=}{27:a-setence}{4: }|
+ {1:~ }│{1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 Xdifile3 }|
+ |
+ ]])
+ command('diffthis')
+ screen:expect(s4)
+
+ -- Test multi-buffer char diff refinement, and that removing a buffer from
+ -- diff will update the others properly.
+ WriteDiffFiles3('abcdefghijkYmYYY', 'aXXdXXghijklmnop', 'abcdefghijkYmYop')
+ command('set diffopt=internal,filler diffopt+=inline:char')
+ local s6 = [[
+ {7: }{4:^a}{27:bcdef}{4:ghijk}{27:YmYYY}{4: }│{7: }{4:a}{27:XXdXX}{4:ghijk}{27:lmnop}{4: }│{7: }{4:a}{27:bcdef}{4:ghijk}{27:YmYop}{4: }|
+ {1:~ }│{1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 Xdifile3 }|
+ |
+ ]]
+ screen:expect(s6)
+ command('diffoff')
+ screen:expect([[
+ ^abcdefghijkYmYYY │{7: }{4:a}{27:XXdXX}{4:ghijk}{27:l}{4:m}{27:n}{4:op }│{7: }{4:a}{27:bcdef}{4:ghijk}{27:Y}{4:m}{27:Y}{4:op }|
+ {1:~ }│{1:~ }│{1:~ }|*17
+ {3:Xdifile1 }{2:Xdifile2 Xdifile3 }|
+ |
+ ]])
+ command('diffthis')
+ screen:expect(s6)
+end)
diff --git a/test/functional/ui/messages_spec.lua b/test/functional/ui/messages_spec.lua
index 9b01150411..94faafa9be 100644
--- a/test/functional/ui/messages_spec.lua
+++ b/test/functional/ui/messages_spec.lua
@@ -229,11 +229,11 @@ describe('ui/ext_messages', function()
{
content = {
{ '\n@character ' },
- { 'xxx', 26, 155 },
+ { 'xxx', 26, 156 },
{ ' ' },
{ 'links to', 18, 5 },
{ ' Character\n@character.special ' },
- { 'xxx', 16, 156 },
+ { 'xxx', 16, 157 },
{ ' ' },
{ 'links to', 18, 5 },
{ ' SpecialChar' },
@@ -300,7 +300,7 @@ describe('ui/ext_messages', function()
cmdline = { { abort = false } },
messages = {
{
- content = { { 'Error', 9, 6 }, { 'Message', 16, 99 } },
+ content = { { 'Error', 9, 6 }, { 'Message', 16, 100 } },
history = true,
kind = 'echoerr',
},
@@ -940,7 +940,7 @@ describe('ui/ext_messages', function()
^ |
{1:~ }|*4
]],
- ruler = { { '0,0-1 All', 9, 61 } },
+ ruler = { { '0,0-1 All', 9, 62 } },
})
command('hi clear MsgArea')
feed('i')
diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim
index 2127945624..fb0af3de0a 100644
--- a/test/old/testdir/gen_opt_test.vim
+++ b/test/old/testdir/gen_opt_test.vim
@@ -214,10 +214,12 @@ let test_values = {
\ 'closeoff', 'hiddenoff', 'foldcolumn:0', 'foldcolumn:12',
\ 'followwrap', 'internal', 'indent-heuristic', 'algorithm:myers',
\ 'icase,iwhite', 'algorithm:minimal', 'algorithm:patience',
- \ 'algorithm:histogram', 'linematch:5'],
+ \ 'algorithm:histogram', 'inline:none', 'inline:simple',
+ \ 'inline:char', 'inline:word', 'inline:char,inline:word', 'linematch:5'],
\ ['xxx', 'foldcolumn:', 'foldcolumn:x', 'foldcolumn:xxx',
\ 'linematch:', 'linematch:x', 'linematch:xxx', 'algorithm:',
- \ 'algorithm:xxx', 'context:', 'context:x', 'context:xxx']],
+ \ 'algorithm:xxx', 'context:', 'context:x', 'context:xxx',
+ \ 'inline:xxx']],
\ 'display': [['', 'lastline', 'truncate', 'uhex', 'lastline,uhex'],
\ ['xxx']],
\ 'eadirection': [['both', 'ver', 'hor'], ['xxx', 'ver,hor']],
diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim
index 87287a57ff..c077eb021a 100644
--- a/test/old/testdir/setup.vim
+++ b/test/old/testdir/setup.vim
@@ -3,7 +3,7 @@ if exists('s:did_load')
set commentstring=/*\ %s\ */
set complete=.,w,b,u,t,i
set define=^\\s*#\\s*define
- set diffopt=internal,filler,closeoff
+ set diffopt=internal,filler,closeoff,inline:simple
set directory^=.
set display=
set fillchars=vert:\|,foldsep:\|,fold:-
diff --git a/test/old/testdir/test_diffmode.vim b/test/old/testdir/test_diffmode.vim
index 0d20085360..b5bfef1f1d 100644
--- a/test/old/testdir/test_diffmode.vim
+++ b/test/old/testdir/test_diffmode.vim
@@ -430,13 +430,13 @@ endfunc
func Common_icase_test()
edit one
- call setline(1, ['One', 'Two', 'Three', 'Four', 'Fi#ve'])
+ call setline(1, ['One', 'Two', 'Three', 'Four', 'Fi#vϵ', 'Si⃗x', 'Se⃗ve⃗n'])
redraw
let normattr = screenattr(1, 1)
diffthis
botright vert new two
- call setline(1, ['one', 'TWO', 'Three ', 'Four', 'fI=VE'])
+ call setline(1, ['one', 'TWO', 'Three ', 'Four', 'fI=VΕ', 'SI⃗x', 'SEvE⃗n'])
diffthis
redraw
@@ -444,10 +444,13 @@ func Common_icase_test()
call assert_equal(normattr, screenattr(2, 1))
call assert_notequal(normattr, screenattr(3, 1))
call assert_equal(normattr, screenattr(4, 1))
+ call assert_equal(normattr, screenattr(6, 2))
+ call assert_notequal(normattr, screenattr(7, 2))
let dtextattr = screenattr(5, 3)
call assert_notequal(dtextattr, screenattr(5, 1))
call assert_notequal(dtextattr, screenattr(5, 5))
+ call assert_notequal(dtextattr, screenattr(7, 4))
diffoff!
%bwipe!
@@ -779,10 +782,10 @@ endfunc
func Test_diff_hlID()
new
- call setline(1, [1, 2, 3])
+ call setline(1, [1, 2, 3, 'Yz', 'a dxxg',])
diffthis
vnew
- call setline(1, ['1x', 2, 'x', 3])
+ call setline(1, ['1x', 2, 'x', 3, 'yx', 'abc defg'])
diffthis
redraw
@@ -793,6 +796,26 @@ func Test_diff_hlID()
call diff_hlID(2, 1)->synIDattr("name")->assert_equal("")
call diff_hlID(3, 1)->synIDattr("name")->assert_equal("DiffAdd")
eval 4->diff_hlID(1)->synIDattr("name")->assert_equal("")
+ call diff_hlID(5, 1)->synIDattr("name")->assert_equal("DiffText")
+ call diff_hlID(5, 2)->synIDattr("name")->assert_equal("DiffText")
+
+ set diffopt+=icase " test that caching is invalidated by diffopt change
+ call diff_hlID(5, 1)->synIDattr("name")->assert_equal("DiffChange")
+ set diffopt-=icase
+ call diff_hlID(5, 1)->synIDattr("name")->assert_equal("DiffText")
+
+ call diff_hlID(6, 1)->synIDattr("name")->assert_equal("DiffChange")
+ call diff_hlID(6, 2)->synIDattr("name")->assert_equal("DiffText")
+ call diff_hlID(6, 4)->synIDattr("name")->assert_equal("DiffText")
+ call diff_hlID(6, 7)->synIDattr("name")->assert_equal("DiffText")
+ call diff_hlID(6, 8)->synIDattr("name")->assert_equal("DiffChange")
+ set diffopt+=inline:char
+ call diff_hlID(6, 1)->synIDattr("name")->assert_equal("DiffChange")
+ call diff_hlID(6, 2)->synIDattr("name")->assert_equal("DiffTextAdd")
+ call diff_hlID(6, 4)->synIDattr("name")->assert_equal("DiffChange")
+ call diff_hlID(6, 7)->synIDattr("name")->assert_equal("DiffText")
+ call diff_hlID(6, 8)->synIDattr("name")->assert_equal("DiffChange")
+ set diffopt-=inline:char
wincmd w
call assert_equal(synIDattr(diff_hlID(1, 1), "name"), "DiffChange")
@@ -2099,6 +2122,178 @@ func Test_diff_topline_noscroll()
call StopVimInTerminal(buf)
endfunc
+" Test inline highlighting which shows what's different within each diff block
+func Test_diff_inline()
+ CheckScreendump
+
+ call WriteDiffFiles(0, [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
+ call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
+
+ call WriteDiffFiles(buf, ["abcdef ghi jk n", "x", "y"], ["aBcef gHi lm n", "y", "z"])
+ call VerifyInternal(buf, "Test_diff_inline_01", "")
+ call VerifyInternal(buf, "Test_diff_inline_02", " diffopt+=inline:none")
+
+ " inline:simple is the same as default
+ call VerifyInternal(buf, "Test_diff_inline_01", " diffopt+=inline:simple")
+
+ call VerifyInternal(buf, "Test_diff_inline_03", " diffopt+=inline:char")
+ call VerifyInternal(buf, "Test_diff_inline_04", " diffopt+=inline:word")
+
+ " multiple inline values will the last one
+ call VerifyInternal(buf, "Test_diff_inline_01", " diffopt+=inline:none,inline:char,inline:simple")
+ call VerifyInternal(buf, "Test_diff_inline_02", " diffopt+=inline:simple,inline:word,inline:none")
+ call VerifyInternal(buf, "Test_diff_inline_03", " diffopt+=inline:simple,inline:word,inline:char")
+
+ " DiffTextAdd highlight
+ call term_sendkeys(buf, ":hi DiffTextAdd ctermbg=blue\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_05", " diffopt+=inline:char")
+
+ " Live update in insert mode
+ call term_sendkeys(buf, "\<Esc>isometext")
+ call VerifyScreenDump(buf, "Test_diff_inline_06", {})
+ call term_sendkeys(buf, "\<Esc>u")
+
+ " icase simple scenarios
+ call VerifyInternal(buf, "Test_diff_inline_07", " diffopt+=inline:simple,icase")
+ call VerifyInternal(buf, "Test_diff_inline_08", " diffopt+=inline:char,icase")
+ call VerifyInternal(buf, "Test_diff_inline_09", " diffopt+=inline:word,icase")
+
+ " diff algorithms should affect highlight
+ call WriteDiffFiles(buf, ["apples and oranges"], ["oranges and apples"])
+ call VerifyInternal(buf, "Test_diff_inline_10", " diffopt+=inline:char")
+ call VerifyInternal(buf, "Test_diff_inline_11", " diffopt+=inline:char,algorithm:patience")
+
+ " icase: composing chars and Unicode fold case edge cases
+ call WriteDiffFiles(buf,
+ \ ["1 - sigma in 6σ and Ὀδυσσεύς", "1 - angstrom in åå", "1 - composing: ii⃗I⃗"],
+ \ ["2 - Sigma in 6Σ and ὈΔΥΣΣΕΎΣ", "2 - Angstrom in ÅÅ", "2 - Composing: i⃗I⃗I⃗"])
+ call VerifyInternal(buf, "Test_diff_inline_12", " diffopt+=inline:char")
+ call VerifyInternal(buf, "Test_diff_inline_13", " diffopt+=inline:char,icase")
+
+ " wide chars
+ call WriteDiffFiles(buf, ["abc😅xde一", "f🚀g"], ["abcy😢de", "二f🚀g"])
+ call VerifyInternal(buf, "Test_diff_inline_14", " diffopt+=inline:char,icase")
+
+ " NUL char (\n below is internally substituted as NUL)
+ call WriteDiffFiles(buf, ["1\n34\n5\n6"], ["1234\n5", "6"])
+ call VerifyInternal(buf, "Test_diff_inline_15", " diffopt+=inline:char")
+
+ " word diff: always use first buffer's iskeyword and ignore others' for consistency
+ call WriteDiffFiles(buf, ["foo+bar test"], ["foo+baz test"])
+ call VerifyInternal(buf, "Test_diff_inline_word_01", " diffopt+=inline:word")
+
+ call term_sendkeys(buf, ":set iskeyword+=+\<CR>:diffupdate\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_word_02", " diffopt+=inline:word")
+
+ call term_sendkeys(buf, ":set iskeyword&\<CR>:wincmd w\<CR>")
+ call term_sendkeys(buf, ":set iskeyword+=+\<CR>:wincmd w\<CR>:diffupdate\<CR>")
+ " Use the previous screen dump as 2nd buffer's iskeyword does not matter
+ call VerifyInternal(buf, "Test_diff_inline_word_01", " diffopt+=inline:word")
+
+ call term_sendkeys(buf, ":windo set iskeyword&\<CR>:1wincmd w\<CR>")
+
+ " char diff: should slide highlight to whitespace boundary if possible for
+ " better readability (by using forced indent-heuristics). A wrong result
+ " would be if the highlight is "Bar, prefix". It should be "prefixBar, "
+ " instead.
+ call WriteDiffFiles(buf, ["prefixFoo, prefixEnd"], ["prefixFoo, prefixBar, prefixEnd"])
+ call VerifyInternal(buf, "Test_diff_inline_char_01", " diffopt+=inline:char")
+
+ " char diff: small gaps between inline diff blocks will be merged during refine step
+ " - first segment: test that we iteratively merge small gaps after we merged
+ " adjacent blocks, but only with limited number (set to 4) of iterations.
+ " - second and third segments: show that we need a large enough adjacent block to
+ " trigger a merge.
+ " - fourth segment: small gaps are not merged when adjacent large block is
+ " on a different line.
+ call WriteDiffFiles(buf,
+ \ ["abcdefghijklmno", "anchor1",
+ \ "abcdefghijklmno", "anchor2",
+ \ "abcdefghijklmno", "anchor3",
+ \ "test", "multiline"],
+ \ ["a?c?e?g?i?k???o", "anchor1",
+ \ "a??de?????klmno", "anchor2",
+ \ "a??de??????lmno", "anchor3",
+ \ "t?s?", "??????i?e"])
+ call VerifyInternal(buf, "Test_diff_inline_char_02", " diffopt+=inline:char")
+
+ " Test multi-line blocks and whitespace
+ call WriteDiffFiles(buf,
+ \ ["this is ", "sometest text foo", "baz abc def ", "one", "word another word", "additional line"],
+ \ ["this is some test", "texts", "foo bar abX Yef ", "oneword another word"])
+ call VerifyInternal(buf, "Test_diff_inline_multiline_01", " diffopt+=inline:char,iwhite")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_02", " diffopt+=inline:word,iwhite")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_03", " diffopt+=inline:char,iwhiteeol")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_04", " diffopt+=inline:word,iwhiteeol")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_05", " diffopt+=inline:char,iwhiteall")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_06", " diffopt+=inline:word,iwhiteall")
+
+ " newline should be highlighted too when 'list' is set
+ call term_sendkeys(buf, ":windo set list\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_07", " diffopt+=inline:char")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_08", " diffopt+=inline:char,iwhite")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_09", " diffopt+=inline:char,iwhiteeol")
+ call VerifyInternal(buf, "Test_diff_inline_multiline_10", " diffopt+=inline:char,iwhiteall")
+ call term_sendkeys(buf, ":windo set nolist\<CR>")
+
+ call StopVimInTerminal(buf)
+endfunc
+
+func Test_diff_inline_multibuffer()
+ CheckScreendump
+
+ call WriteDiffFiles3(0, [], [], [])
+ let buf = RunVimInTerminal('-d Xdifile1 Xdifile2 Xdifile3', {})
+ call term_sendkeys(buf, ":windo set autoread\<CR>:1wincmd w\<CR>")
+ call term_sendkeys(buf, ":hi DiffTextAdd ctermbg=blue\<CR>")
+
+ call WriteDiffFiles3(buf,
+ \ ["That is buffer1.", "anchor", "Some random text", "anchor"],
+ \ ["This is buffer2.", "anchor", "Some text", "anchor", "buffer2/3"],
+ \ ["This is buffer3. Last.", "anchor", "Some more", "text here.", "anchor", "only in buffer2/3", "not in buffer1"])
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_01", " diffopt+=inline:char")
+
+ " Close one of the buffer and make sure it updates correctly
+ call term_sendkeys(buf, ":diffoff\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_02", " diffopt+=inline:char")
+
+ " Update text in the non-diff buffer and nothing should be changed
+ call term_sendkeys(buf, "\<Esc>isometext")
+ call VerifyScreenDump(buf, "Test_diff_inline_multibuffer_03", {})
+ call term_sendkeys(buf, "\<Esc>u")
+
+ call term_sendkeys(buf, ":diffthis\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_01", " diffopt+=inline:char")
+
+ " Test that removing first buffer from diff will in turn use the next
+ " earliest buffer's iskeyword during word diff.
+ call WriteDiffFiles3(buf,
+ \ ["This+is=a-setence"],
+ \ ["This+is=another-setence"],
+ \ ["That+is=a-setence"])
+ call term_sendkeys(buf, ":set iskeyword+=+\<CR>:2wincmd w\<CR>:set iskeyword+=-\<CR>:1wincmd w\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_04", " diffopt+=inline:word")
+ call term_sendkeys(buf, ":diffoff\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_05", " diffopt+=inline:word")
+ call term_sendkeys(buf, ":diffthis\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_04", " diffopt+=inline:word")
+
+ " Test multi-buffer char diff refinement, and that removing a buffer from
+ " diff will update the others properly.
+ call WriteDiffFiles3(buf,
+ \ ["abcdefghijkYmYYY"],
+ \ ["aXXdXXghijklmnop"],
+ \ ["abcdefghijkYmYop"])
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_06", " diffopt+=inline:char")
+ call term_sendkeys(buf, ":diffoff\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_07", " diffopt+=inline:char")
+ call term_sendkeys(buf, ":diffthis\<CR>")
+ call VerifyInternal(buf, "Test_diff_inline_multibuffer_06", " diffopt+=inline:char")
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_diffget_diffput_linematch()
CheckScreendump
call delete('.Xdifile1.swp')
diff --git a/test/old/testdir/test_options.vim b/test/old/testdir/test_options.vim
index 9d8122cd8b..f3dcb3bbb7 100644
--- a/test/old/testdir/test_options.vim
+++ b/test/old/testdir/test_options.vim
@@ -629,10 +629,11 @@ func Test_set_completion_string_values()
" call assert_equal([], getcompletion('set completepopup=bogusname:', 'cmdline'))
" set previewpopup& completepopup&
- " diffopt: special handling of algorithm:<alg_list>
+ " diffopt: special handling of algorithm:<alg_list> and inline:<inline_type>
call assert_equal('filler', getcompletion('set diffopt+=', 'cmdline')[0])
call assert_equal([], getcompletion('set diffopt+=iblank,foldcolumn:', 'cmdline'))
call assert_equal('patience', getcompletion('set diffopt+=iblank,algorithm:pat*', 'cmdline')[0])
+ call assert_equal('char', getcompletion('set diffopt+=iwhite,inline:ch*', 'cmdline')[0])
" highlight: special parsing, including auto-completing highlight groups
" after ':'
@@ -722,7 +723,7 @@ func Test_set_completion_string_values()
call assert_equal([], getcompletion('set diffopt-=', 'cmdline'))
" Test all possible values
call assert_equal(['filler', 'context:', 'iblank', 'icase', 'iwhite', 'iwhiteall', 'iwhiteeol', 'horizontal',
- \ 'vertical', 'closeoff', 'hiddenoff', 'foldcolumn:', 'followwrap', 'internal', 'indent-heuristic', 'algorithm:', 'linematch:'],
+ \ 'vertical', 'closeoff', 'hiddenoff', 'foldcolumn:', 'followwrap', 'internal', 'indent-heuristic', 'algorithm:', 'inline:', 'linematch:'],
\ getcompletion('set diffopt=', 'cmdline'))
set diffopt&