diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index dba8a8a877..0118597eb8 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -17,7 +17,6 @@ SCRIPTS := \ test37.out \ test40.out \ test42.out \ - test47.out \ test48.out \ test49.out \ test52.out \ @@ -33,6 +32,7 @@ SCRIPTS := \ NEW_TESTS = \ test_cscope.res \ test_cmdline.res \ + test_diffmode.res \ test_hardcopy.res \ test_help_tagjump.res \ test_history.res \ diff --git a/src/nvim/testdir/test47.in b/src/nvim/testdir/test47.in deleted file mode 100644 index c95c6a6850..0000000000 --- a/src/nvim/testdir/test47.in +++ /dev/null @@ -1,102 +0,0 @@ -Tests for vertical splits and filler lines in diff mode - -Also tests restoration of saved options by :diffoff. - -STARTTEST -:" Disable the title to avoid xterm keeping the wrong one. -:set notitle noicon -/^1 -yG:new -pkdd:w! Xtest -ddGpkkrXoxxx:w! Xtest2 -:file Nop -ggoyyyjjjozzzz -:set foldmethod=marker foldcolumn=4 -:redir => nodiffsettings -:silent! :set diff? fdm? fdc? scb? crb? wrap? -:redir END -:vert diffsplit Xtest -:vert diffsplit Xtest2 -:redir => diffsettings -:silent! :set diff? fdm? fdc? scb? crb? wrap? -:redir END -:let diff_fdm = &fdm -:let diff_fdc = &fdc -:" repeat entering diff mode here to see if this saves the wrong settings -:diffthis -:" jump to second window for a moment to have filler line appear at start of -:" first window -ggpgg:let one = winline() -j:let one = one . "-" . winline() -j:let one = one . "-" . winline() -j:let one = one . "-" . winline() -j:let one = one . "-" . winline() -j:let one = one . "-" . winline() -gg:let two = winline() -j:let two = two . "-" . winline() -j:let two = two . "-" . winline() -j:let two = two . "-" . winline() -j:let two = two . "-" . winline() -gg:let three = winline() -j:let three = three . "-" . winline() -j:let three = three . "-" . winline() -j:let three = three . "-" . winline() -j:let three = three . "-" . winline() -j:let three = three . "-" . winline() -j:let three = three . "-" . winline() -:call append("$", one) -:call append("$", two) -:call append("$", three) -:$-2,$w! test.out -:" -:" Test diffoff -:diffoff! -1 -:let &diff = 1 -:let &fdm = diff_fdm -:let &fdc = diff_fdc -4 -:diffoff! -:$put =nodiffsettings -:$put =diffsettings -1 -:redir => nd1 -:silent! :set diff? fdm? fdc? scb? crb? wrap? -:redir END - -:redir => nd2 -:silent! :set diff? fdm? fdc? scb? crb? wrap? -:redir END - -:redir => nd3 -:silent! :set diff? fdm? fdc? scb? crb? wrap? -:redir END - -:$put =nd1 -:$put =nd2 -:$put =nd3 -:$-39,$w >> test.out -:" -:" Test that diffing shows correct filler lines -:windo :bw! -:enew -:put =range(4,10) -:1d _ -:vnew -:put =range(1,10) -:1d _ -:windo :diffthis -:wincmd h -:let w0=line('w0') -:enew -:put =w0 -:.w >> test.out -:unlet! one two three nodiffsettings diffsettings diff_fdm diff_fdc nd1 nd2 nd3 w0 -:qa! -ENDTEST - -1 aa -2 bb -3 cc -4 dd -5 ee diff --git a/src/nvim/testdir/test47.ok b/src/nvim/testdir/test47.ok deleted file mode 100644 index 83e96571ad..0000000000 --- a/src/nvim/testdir/test47.ok +++ /dev/null @@ -1,44 +0,0 @@ -2-4-5-6-8-9 -1-2-4-5-8 -2-3-4-5-6-7-8 - - -nodiff - foldmethod=marker - foldcolumn=4 -noscrollbind -nocursorbind - wrap - - - diff - foldmethod=diff - foldcolumn=2 - scrollbind - cursorbind -nowrap - - -nodiff - foldmethod=marker - foldcolumn=4 -noscrollbind -nocursorbind - wrap - - -nodiff - foldmethod=marker - foldcolumn=4 -noscrollbind -nocursorbind - wrap - - -nodiff - foldmethod=marker - foldcolumn=4 -noscrollbind -nocursorbind - wrap -1 diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim new file mode 100644 index 0000000000..e5d9ff94d9 --- /dev/null +++ b/src/nvim/testdir/test_diffmode.vim @@ -0,0 +1,165 @@ +" Tests for diff mode + +func Test_diff_fold_sync() + enew! + let l = range(50) + call setline(1, l) + diffthis + let winone = win_getid() + new + let l[25] = 'diff' + call setline(1, l) + diffthis + let wintwo = win_getid() + " line 15 is inside the closed fold + call assert_equal(19, foldclosedend(10)) + call win_gotoid(winone) + call assert_equal(19, foldclosedend(10)) + " open the fold + normal zv + call assert_equal(-1, foldclosedend(10)) + " fold in other window must have opened too + call win_gotoid(wintwo) + call assert_equal(-1, foldclosedend(10)) + + " cursor position is in sync + normal 23G + call win_gotoid(winone) + call assert_equal(23, getcurpos()[1]) + + windo diffoff + close! + set nomodified +endfunc + +func Test_vert_split() + " Disable the title to avoid xterm keeping the wrong one. + set notitle noicon + new + let l = ['1 aa', '2 bb', '3 cc', '4 dd', '5 ee'] + call setline(1, l) + w! Xtest + normal dd + $ + put + normal kkrXoxxx + w! Xtest2 + file Nop + normal ggoyyyjjjozzzz + set foldmethod=marker foldcolumn=4 + call assert_equal(0, &diff) + call assert_equal('marker', &foldmethod) + call assert_equal(4, &foldcolumn) + call assert_equal(0, &scrollbind) + call assert_equal(0, &cursorbind) + call assert_equal(1, &wrap) + + vert diffsplit Xtest + vert diffsplit Xtest2 + call assert_equal(1, &diff) + call assert_equal('diff', &foldmethod) + call assert_equal(2, &foldcolumn) + call assert_equal(1, &scrollbind) + call assert_equal(1, &cursorbind) + call assert_equal(0, &wrap) + + let diff_fdm = &fdm + let diff_fdc = &fdc + " repeat entering diff mode here to see if this saves the wrong settings + diffthis + " jump to second window for a moment to have filler line appear at start of + " first window + wincmd w + normal gg + wincmd p + normal gg + call assert_equal(2, winline()) + normal j + call assert_equal(4, winline()) + normal j + call assert_equal(5, winline()) + normal j + call assert_equal(6, winline()) + normal j + call assert_equal(8, winline()) + normal j + call assert_equal(9, winline()) + + wincmd w + normal gg + call assert_equal(1, winline()) + normal j + call assert_equal(2, winline()) + normal j + call assert_equal(4, winline()) + normal j + call assert_equal(5, winline()) + normal j + call assert_equal(8, winline()) + + wincmd w + normal gg + call assert_equal(2, winline()) + normal j + call assert_equal(3, winline()) + normal j + call assert_equal(4, winline()) + normal j + call assert_equal(5, winline()) + normal j + call assert_equal(6, winline()) + normal j + call assert_equal(7, winline()) + normal j + call assert_equal(8, winline()) + + " Test diffoff + diffoff! + 1wincmd 2 + let &diff = 1 + let &fdm = diff_fdm + let &fdc = diff_fdc + 4wincmd w + diffoff! + 1wincmd w + call assert_equal(0, &diff) + call assert_equal('marker', &foldmethod) + call assert_equal(4, &foldcolumn) + call assert_equal(0, &scrollbind) + call assert_equal(0, &cursorbind) + call assert_equal(1, &wrap) + + wincmd w + call assert_equal(0, &diff) + call assert_equal('marker', &foldmethod) + call assert_equal(4, &foldcolumn) + call assert_equal(0, &scrollbind) + call assert_equal(0, &cursorbind) + call assert_equal(1, &wrap) + + wincmd w + call assert_equal(0, &diff) + call assert_equal('marker', &foldmethod) + call assert_equal(4, &foldcolumn) + call assert_equal(0, &scrollbind) + call assert_equal(0, &cursorbind) + call assert_equal(1, &wrap) + + windo bw! +endfunc + +func Test_filler_lines() + " Test that diffing shows correct filler lines + enew! + put =range(4,10) + 1d _ + vnew + put =range(1,10) + 1d _ + windo diffthis + wincmd h + call assert_equal(1, line('w0')) + unlet! diff_fdm diff_fdc + + windo bw! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index cd7b70b027..ce103ec7dd 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -317,7 +317,7 @@ static int included_patches[] = { // 2126, // 2125, // 2124, - // 2123, + 2123, // 2122 NA // 2121, // 2120,