summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-30 16:16:54 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-30 16:16:54 +0200
commit42093c0ec52e6ff29e80aae65ac6a744c7de79bb (patch)
treeb74f9656b465fc84bba544cba5b6123057843ab8
parentb822cb0f93177bb045b221f607aee735f08ce428 (diff)
downloadvim-git-42093c0ec52e6ff29e80aae65ac6a744c7de79bb.tar.gz
patch 7.4.2123v7.4.2123
Problem: No new style test for diff mode. Solution: Add a test. Check that folds are in sync.
-rw-r--r--src/Makefile3
-rw-r--r--src/testdir/Make_all.mak2
-rw-r--r--src/testdir/test47.in103
-rw-r--r--src/testdir/test47.ok44
-rw-r--r--src/testdir/test_diffmode.vim165
-rw-r--r--src/version.c2
6 files changed, 170 insertions, 149 deletions
diff --git a/src/Makefile b/src/Makefile
index 7ef6e90c2..6d49e9046 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -2042,7 +2042,7 @@ test1 \
test11 test12 test13 test14 test15 test16 test17 test18 test19 \
test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \
test30 test31 test32 test33 test34 test36 test37 test38 test39 \
- test40 test41 test42 test43 test44 test45 test46 test47 test48 test49 \
+ test40 test41 test42 test43 test44 test45 test46 test48 test49 \
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
test60 test62 test63 test64 test65 test66 test67 test68 test69 \
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
@@ -2064,6 +2064,7 @@ test_arglist \
test_cscope \
test_cursor_func \
test_delete \
+ test_diffmode \
test_digraph \
test_ex_undo \
test_execute_func \
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index ced52e0a3..2965b708d 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -43,7 +43,6 @@ SCRIPTS_ALL = \
test44.out \
test45.out \
test46.out \
- test47.out \
test48.out \
test51.out \
test53.out \
@@ -168,6 +167,7 @@ NEW_TESTS = test_arglist.res \
test_channel.res \
test_cmdline.res \
test_cscope.res \
+ test_diffmode.res \
test_digraph.res \
test_farsi.res \
test_gn.res \
diff --git a/src/testdir/test47.in b/src/testdir/test47.in
deleted file mode 100644
index f15eaf0f8..000000000
--- a/src/testdir/test47.in
+++ /dev/null
@@ -1,103 +0,0 @@
-Tests for vertical splits and filler lines in diff mode
-
-Also tests restoration of saved options by :diffoff.
-
-STARTTEST
-:so small.vim
-:" 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/testdir/test47.ok b/src/testdir/test47.ok
deleted file mode 100644
index 83e96571a..000000000
--- a/src/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/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
new file mode 100644
index 000000000..e5d9ff94d
--- /dev/null
+++ b/src/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/version.c b/src/version.c
index 65ec6b636..ae7b4de1b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2123,
+/**/
2122,
/**/
2121,