mirror of
https://github.com/neovim/neovim.git
synced 2026-04-21 14:55:33 +00:00
vim-patch:9.1.1753: defaults: 'diffopt' option value can be improved (#35727)
Problem: defaults: 'diffopt' option value can be improved
Solution: Update diffopt defaults to include "indent-heuristic" and
"inline:char" (Yee Cheng Chin)
The default diff options have not been updated much despite new
functionality having been added to Vim.
- indent-heurstic: This has been enabled by default in Git since
33de716387 in 2017. Given that Vim uses xdiff from Git, it makes sense
to track the default configuration from Git.
- inline:char: This turns on character-wise inline highlighting which is
generally much better than the default inline:simple. It has been
implemented since vim/vim#16881 and we have not seen reports of any issues
with it, and it has received good feedbacks.
closes: vim/vim#18255
976b365305
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
This commit is contained in:
@@ -850,6 +850,7 @@ func Test_diff_nomodifiable()
|
||||
endfunc
|
||||
|
||||
func Test_diff_hlID()
|
||||
set diffopt=internal,filler
|
||||
new
|
||||
call setline(1, [1, 2, 3, 'Yz', 'a dxxg',])
|
||||
diffthis
|
||||
@@ -892,6 +893,7 @@ func Test_diff_hlID()
|
||||
call assert_equal(synIDattr(diff_hlID(3, 1), "name"), "")
|
||||
|
||||
%bwipe!
|
||||
set diffopt&
|
||||
endfunc
|
||||
|
||||
func Test_diff_filler()
|
||||
@@ -1060,18 +1062,18 @@ func Test_diff_screen()
|
||||
call term_sendkeys(buf, ":set diffopt+=algorithm:histogram\<cr>")
|
||||
call VerifyScreenDump(buf, 'Test_diff_09', {})
|
||||
|
||||
" Test 10-11: normal/indent-heuristic
|
||||
" Test 10-11: with/without indent-heuristic
|
||||
call term_sendkeys(buf, ":set diffopt&vim\<cr>")
|
||||
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>")
|
||||
call term_sendkeys(buf, ":set diffopt+=internal\<cr>")
|
||||
call VerifyScreenDump(buf, 'Test_diff_10', {})
|
||||
call term_sendkeys(buf, ":set diffopt+=internal\<cr>:\<cr>")
|
||||
call VerifyScreenDump(buf, 'Test_diff_11', {})
|
||||
|
||||
" Leave trailing : at commandline!
|
||||
call term_sendkeys(buf, ":set diffopt+=indent-heuristic\<cr>:\<cr>")
|
||||
call VerifyScreenDump(buf, 'Test_diff_11', {}, 'one')
|
||||
call term_sendkeys(buf, ":set diffopt-=indent-heuristic\<cr>:\<cr>")
|
||||
call VerifyScreenDump(buf, 'Test_diff_10', {}, 'one')
|
||||
" shouldn't matter, if indent-algorithm comes before or after the algorithm
|
||||
call term_sendkeys(buf, ":set diffopt&\<cr>")
|
||||
call term_sendkeys(buf, ":set diffopt+=indent-heuristic,algorithm:patience\<cr>:\<cr>")
|
||||
@@ -1312,6 +1314,7 @@ func Test_diff_with_syntax()
|
||||
call writefile(lines, 'Xprogram2.c', 'D')
|
||||
|
||||
let lines =<< trim END
|
||||
set diffopt=internal,filler
|
||||
edit Xprogram1.c
|
||||
diffsplit Xprogram2.c
|
||||
END
|
||||
@@ -1454,9 +1457,7 @@ func Test_diff_rnu()
|
||||
CheckScreendump
|
||||
|
||||
let content =<< trim END
|
||||
call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
|
||||
vnew
|
||||
call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
|
||||
set diffopt=internal,filler
|
||||
call setline(1, ['a', 'a', 'a', 'y', 'b', 'b', 'b', 'b', 'b'])
|
||||
vnew
|
||||
call setline(1, ['a', 'a', 'a', 'x', 'x', 'x', 'b', 'b', 'b', 'b', 'b'])
|
||||
@@ -1544,6 +1545,7 @@ endfunc
|
||||
" Test for adding/removing lines inside diff chunks, between diff chunks
|
||||
" and before diff chunks
|
||||
func Test_diff_modify_chunks()
|
||||
set diffopt=internal,filler
|
||||
enew!
|
||||
let w2_id = win_getid()
|
||||
call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'])
|
||||
@@ -1623,6 +1625,7 @@ func Test_diff_modify_chunks()
|
||||
call assert_equal(['', '', '', '', '', '', '', '', ''], hl)
|
||||
|
||||
%bw!
|
||||
set diffopt&
|
||||
endfunc
|
||||
|
||||
func Test_diff_binary()
|
||||
@@ -2616,7 +2619,7 @@ func Test_linematch_diff()
|
||||
call delete('.Xdifile2.swp')
|
||||
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 term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
|
||||
|
||||
" enable linematch
|
||||
call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
|
||||
@@ -2644,7 +2647,7 @@ func Test_linematch_diff_iwhite()
|
||||
call delete('.Xdifile2.swp')
|
||||
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 term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
|
||||
|
||||
" setup a diff with 2 files and set linematch:30, with ignore white
|
||||
call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
|
||||
@@ -2671,7 +2674,7 @@ func Test_linematch_diff_grouping()
|
||||
call delete('.Xdifile2.swp')
|
||||
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 term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
|
||||
|
||||
" a diff that would result in multiple groups before grouping optimization
|
||||
call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
|
||||
@@ -2709,7 +2712,7 @@ func Test_linematch_diff_scroll()
|
||||
call delete('.Xdifile2.swp')
|
||||
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 term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
|
||||
|
||||
" a diff that would result in multiple groups before grouping optimization
|
||||
call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
|
||||
@@ -2740,7 +2743,7 @@ func Test_linematch_line_limit_exceeded()
|
||||
call delete('.Xdifile1.swp')
|
||||
call delete('.Xdifile2.swp')
|
||||
call WriteDiffFiles(0, [], [])
|
||||
let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
|
||||
let buf = RunVimInTerminal('-d Xdifile1 Xdifile2', {})
|
||||
call term_sendkeys(buf, ":set autoread\<CR>\<c-w>w:set autoread\<CR>\<c-w>w")
|
||||
|
||||
call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:10\<CR>")
|
||||
@@ -2792,7 +2795,7 @@ func Test_linematch_3diffs()
|
||||
call delete('.Xdifile3.swp')
|
||||
call WriteDiffFiles3(0, [], [], [])
|
||||
let buf = RunVimInTerminal('-d Xdifile1 Xdifile2 Xdifile3', {})
|
||||
call term_sendkeys(buf, "1\<c-w>w:set autoread\<CR>")
|
||||
call term_sendkeys(buf, "1\<c-w>w:set autoread\<CR>")
|
||||
call term_sendkeys(buf, "2\<c-w>w:set autoread\<CR>")
|
||||
call term_sendkeys(buf, "3\<c-w>w:set autoread\<CR>")
|
||||
call term_sendkeys(buf, ":set diffopt=internal,filler,linematch:30\<CR>")
|
||||
@@ -2827,7 +2830,7 @@ func Test_linematch_3diffs_sanity_check()
|
||||
func Test_linematch_3diffs_sanity_check()
|
||||
CheckScreendump
|
||||
call delete('.Xfile_linematch1.swp')
|
||||
call delete('.Xfile_linematch2.swp')
|
||||
call delete('.Xfile_linematch2.swp')
|
||||
call delete('.Xfile_linematch3.swp')
|
||||
let lines =<< trim END
|
||||
set diffopt=internal,filler,linematch:60
|
||||
|
||||
Reference in New Issue
Block a user