mirror of
https://github.com/vim/vim.git
synced 2025-10-04 05:25:06 -04:00
patch 8.1.0393: not all white space difference options available
Problem: Not all white space difference options available. Solution: Add "iblank", "iwhiteall" and "iwhiteeol" to 'diffopt'.
This commit is contained in:
@@ -671,16 +671,18 @@ func Test_diff_lastline()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func WriteDiffFiles(list1, list2)
|
||||
func WriteDiffFiles(buf, list1, list2)
|
||||
call writefile(a:list1, 'Xfile1')
|
||||
call writefile(a:list2, 'Xfile2')
|
||||
if a:buf
|
||||
call term_sendkeys(a:buf, ":checktime\<CR>")
|
||||
endif
|
||||
endfunc
|
||||
|
||||
" Verify a screendump with both the external and external diff.
|
||||
" Verify a screendump with both the internal and external diff.
|
||||
func VerifyBoth(buf, dumpfile, extra)
|
||||
call term_sendkeys(a:buf, ":diffupdate!\<cr>")
|
||||
" trailing : for leaving the cursor on the command line
|
||||
for cmd in [":set diffopt=filler" . a:extra . "\<cr>:", ":set diffopt+=internal\<cr>:"]
|
||||
for cmd in [":set diffopt=filler" . a:extra . "\<CR>:", ":set diffopt+=internal\<CR>:"]
|
||||
call term_sendkeys(a:buf, cmd)
|
||||
if VerifyScreenDump(a:buf, a:dumpfile, {}, cmd =~ 'internal' ? 'internal' : 'external')
|
||||
break " don't let the next iteration overwrite the "failed" file.
|
||||
@@ -688,6 +690,14 @@ func VerifyBoth(buf, dumpfile, extra)
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
" Verify a screendump with the internal diff only.
|
||||
func VerifyInternal(buf, dumpfile, extra)
|
||||
call term_sendkeys(a:buf, ":diffupdate!\<CR>")
|
||||
" trailing : for leaving the cursor on the command line
|
||||
call term_sendkeys(a:buf, ":set diffopt=internal,filler" . a:extra . "\<CR>:")
|
||||
call VerifyScreenDump(a:buf, a:dumpfile, {})
|
||||
endfunc
|
||||
|
||||
func Test_diff_screen()
|
||||
if !CanRunVimInTerminal() || !has('menu')
|
||||
return
|
||||
@@ -697,36 +707,36 @@ func Test_diff_screen()
|
||||
call delete('.Xfile2.swp')
|
||||
|
||||
" Test 1: Add a line in beginning of file 2
|
||||
call WriteDiffFiles([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
call WriteDiffFiles(0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
let buf = RunVimInTerminal('-d Xfile1 Xfile2', {})
|
||||
" Set autoread mode, ,so that Vim won't complain once we re-write the test
|
||||
" files
|
||||
call term_sendkeys(buf, ":set autoread\<cr>\<c-w>w:set autoread\<cr>\<c-w>w")
|
||||
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
|
||||
|
||||
call VerifyBoth(buf, 'Test_diff_01', '')
|
||||
|
||||
" Test 2: Add a line in beginning of file 1
|
||||
call WriteDiffFiles([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
call WriteDiffFiles(buf, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
call VerifyBoth(buf, 'Test_diff_02', '')
|
||||
|
||||
" Test 3: Add a line at the end of file 2
|
||||
call WriteDiffFiles([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
|
||||
call WriteDiffFiles(buf, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
|
||||
call VerifyBoth(buf, 'Test_diff_03', '')
|
||||
|
||||
" Test 4: Add a line at the end of file 1
|
||||
call WriteDiffFiles([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
call WriteDiffFiles(buf, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
call VerifyBoth(buf, 'Test_diff_04', '')
|
||||
|
||||
" Test 5: Add a line in the middle of file 2, remove on at the end of file 1
|
||||
call WriteDiffFiles([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10])
|
||||
call WriteDiffFiles(buf, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10])
|
||||
call VerifyBoth(buf, 'Test_diff_05', '')
|
||||
|
||||
" Test 6: Add a line in the middle of file 1, remove on at the end of file 2
|
||||
call WriteDiffFiles([1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
|
||||
call WriteDiffFiles(buf, [1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
|
||||
call VerifyBoth(buf, 'Test_diff_06', '')
|
||||
|
||||
" Test 7 - 9: Test normal/patience/histogram diff algorithm
|
||||
call WriteDiffFiles(['#include <stdio.h>', '', '// Frobs foo heartily', 'int frobnitz(int foo)', '{',
|
||||
call WriteDiffFiles(buf, ['#include <stdio.h>', '', '// Frobs foo heartily', 'int frobnitz(int foo)', '{',
|
||||
\ ' int i;', ' for(i = 0; i < 10; i++)', ' {', ' printf("Your answer is: ");',
|
||||
\ ' printf("%d\n", foo);', ' }', '}', '', 'int fact(int n)', '{', ' if(n > 1)', ' {',
|
||||
\ ' return fact(n-1) * n;', ' }', ' return 1;', '}', '', 'int main(int argc, char **argv)',
|
||||
@@ -748,7 +758,7 @@ func Test_diff_screen()
|
||||
|
||||
" Test 10-11: normal/indent-heuristic
|
||||
call term_sendkeys(buf, ":set diffopt&vim\<cr>")
|
||||
call WriteDiffFiles(['', ' def finalize(values)', '', ' values.each do |v|', ' v.finalize', ' end'],
|
||||
call WriteDiffFiles(buf, ['', ' def finalize(values)', '', ' values.each do |v|', ' v.finalize', ' end'],
|
||||
\ ['', ' def finalize(values)', '', ' values.each do |v|', ' v.prepare', ' end', '',
|
||||
\ ' values.each do |v|', ' v.finalize', ' end'])
|
||||
call term_sendkeys(buf, ":diffupdate!\<cr>")
|
||||
@@ -759,19 +769,19 @@ func Test_diff_screen()
|
||||
call VerifyScreenDump(buf, 'Test_diff_11', {})
|
||||
|
||||
" Test 12: diff the same file
|
||||
call WriteDiffFiles([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
call WriteDiffFiles(buf, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
|
||||
call VerifyBoth(buf, 'Test_diff_12', '')
|
||||
|
||||
" Test 13: diff an empty file
|
||||
call WriteDiffFiles([], [])
|
||||
call WriteDiffFiles(buf, [], [])
|
||||
call VerifyBoth(buf, 'Test_diff_13', '')
|
||||
|
||||
" Test 14: test diffopt+=icase
|
||||
call WriteDiffFiles(['a', 'b', 'cd'], ['A', 'b', 'cDe'])
|
||||
call WriteDiffFiles(buf, ['a', 'b', 'cd'], ['A', 'b', 'cDe'])
|
||||
call VerifyBoth(buf, 'Test_diff_14', " diffopt+=filler diffopt+=icase")
|
||||
|
||||
" Test 15-16: test diffopt+=iwhite
|
||||
call WriteDiffFiles(['int main()', '{', ' printf("Hello, World!");', ' return 0;', '}'],
|
||||
call WriteDiffFiles(buf, ['int main()', '{', ' printf("Hello, World!");', ' return 0;', '}'],
|
||||
\ ['int main()', '{', ' if (0)', ' {', ' printf("Hello, World!");', ' return 0;', ' }', '}'])
|
||||
call term_sendkeys(buf, ":diffupdate!\<cr>")
|
||||
call term_sendkeys(buf, ":set diffopt&vim diffopt+=filler diffopt+=iwhite\<cr>")
|
||||
@@ -779,6 +789,22 @@ func Test_diff_screen()
|
||||
call term_sendkeys(buf, ":set diffopt+=internal\<cr>")
|
||||
call VerifyScreenDump(buf, 'Test_diff_16', {})
|
||||
|
||||
" Test 17: test diffopt+=iblank
|
||||
call WriteDiffFiles(buf, ['a', ' ', 'cd', 'ef', 'xxx'], ['a', 'cd', '', 'ef', 'yyy'])
|
||||
call VerifyInternal(buf, 'Test_diff_17', " diffopt+=iblank")
|
||||
|
||||
" Test 18: test diffopt+=iblank,iwhite / iwhiteall / iwhiteeol
|
||||
call VerifyInternal(buf, 'Test_diff_18', " diffopt+=iblank,iwhite")
|
||||
call VerifyInternal(buf, 'Test_diff_18', " diffopt+=iblank,iwhiteall")
|
||||
call VerifyInternal(buf, 'Test_diff_18', " diffopt+=iblank,iwhiteeol")
|
||||
|
||||
" Test 19: test diffopt+=iwhiteeol
|
||||
call WriteDiffFiles(buf, ['a ', 'x', 'cd', 'ef', 'xx xx', 'foo', 'bar'], ['a', 'x', 'c d', ' ef', 'xx xx', 'foo', '', 'bar'])
|
||||
call VerifyInternal(buf, 'Test_diff_19', " diffopt+=iwhiteeol")
|
||||
|
||||
" Test 19: test diffopt+=iwhiteall
|
||||
call VerifyInternal(buf, 'Test_diff_20', " diffopt+=iwhiteall")
|
||||
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('Xfile1')
|
||||
|
Reference in New Issue
Block a user