Skip to content

Commit 42093c0

Browse files
committed
patch 7.4.2123
Problem: No new style test for diff mode. Solution: Add a test. Check that folds are in sync.
1 parent b822cb0 commit 42093c0

6 files changed

Lines changed: 170 additions & 149 deletions

File tree

src/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ test1 \
20422042
test11 test12 test13 test14 test15 test16 test17 test18 test19 \
20432043
test20 test21 test22 test23 test24 test25 test26 test27 test28 test29 \
20442044
test30 test31 test32 test33 test34 test36 test37 test38 test39 \
2045-
test40 test41 test42 test43 test44 test45 test46 test47 test48 test49 \
2045+
test40 test41 test42 test43 test44 test45 test46 test48 test49 \
20462046
test50 test51 test52 test53 test54 test55 test56 test57 test58 test59 \
20472047
test60 test62 test63 test64 test65 test66 test67 test68 test69 \
20482048
test70 test71 test72 test73 test74 test75 test76 test77 test78 test79 \
@@ -2064,6 +2064,7 @@ test_arglist \
20642064
test_cscope \
20652065
test_cursor_func \
20662066
test_delete \
2067+
test_diffmode \
20672068
test_digraph \
20682069
test_ex_undo \
20692070
test_execute_func \

src/testdir/Make_all.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ SCRIPTS_ALL = \
4343
test44.out \
4444
test45.out \
4545
test46.out \
46-
test47.out \
4746
test48.out \
4847
test51.out \
4948
test53.out \
@@ -168,6 +167,7 @@ NEW_TESTS = test_arglist.res \
168167
test_channel.res \
169168
test_cmdline.res \
170169
test_cscope.res \
170+
test_diffmode.res \
171171
test_digraph.res \
172172
test_farsi.res \
173173
test_gn.res \

src/testdir/test47.in

Lines changed: 0 additions & 103 deletions
This file was deleted.

src/testdir/test47.ok

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/testdir/test_diffmode.vim

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
" Tests for diff mode
2+
3+
func Test_diff_fold_sync()
4+
enew!
5+
let l = range(50)
6+
call setline(1, l)
7+
diffthis
8+
let winone = win_getid()
9+
new
10+
let l[25] = 'diff'
11+
call setline(1, l)
12+
diffthis
13+
let wintwo = win_getid()
14+
" line 15 is inside the closed fold
15+
call assert_equal(19, foldclosedend(10))
16+
call win_gotoid(winone)
17+
call assert_equal(19, foldclosedend(10))
18+
" open the fold
19+
normal zv
20+
call assert_equal(-1, foldclosedend(10))
21+
" fold in other window must have opened too
22+
call win_gotoid(wintwo)
23+
call assert_equal(-1, foldclosedend(10))
24+
25+
" cursor position is in sync
26+
normal 23G
27+
call win_gotoid(winone)
28+
call assert_equal(23, getcurpos()[1])
29+
30+
windo diffoff
31+
close!
32+
set nomodified
33+
endfunc
34+
35+
func Test_vert_split()
36+
" Disable the title to avoid xterm keeping the wrong one.
37+
set notitle noicon
38+
new
39+
let l = ['1 aa', '2 bb', '3 cc', '4 dd', '5 ee']
40+
call setline(1, l)
41+
w! Xtest
42+
normal dd
43+
$
44+
put
45+
normal kkrXoxxx
46+
w! Xtest2
47+
file Nop
48+
normal ggoyyyjjjozzzz
49+
set foldmethod=marker foldcolumn=4
50+
call assert_equal(0, &diff)
51+
call assert_equal('marker', &foldmethod)
52+
call assert_equal(4, &foldcolumn)
53+
call assert_equal(0, &scrollbind)
54+
call assert_equal(0, &cursorbind)
55+
call assert_equal(1, &wrap)
56+
57+
vert diffsplit Xtest
58+
vert diffsplit Xtest2
59+
call assert_equal(1, &diff)
60+
call assert_equal('diff', &foldmethod)
61+
call assert_equal(2, &foldcolumn)
62+
call assert_equal(1, &scrollbind)
63+
call assert_equal(1, &cursorbind)
64+
call assert_equal(0, &wrap)
65+
66+
let diff_fdm = &fdm
67+
let diff_fdc = &fdc
68+
" repeat entering diff mode here to see if this saves the wrong settings
69+
diffthis
70+
" jump to second window for a moment to have filler line appear at start of
71+
" first window
72+
wincmd w
73+
normal gg
74+
wincmd p
75+
normal gg
76+
call assert_equal(2, winline())
77+
normal j
78+
call assert_equal(4, winline())
79+
normal j
80+
call assert_equal(5, winline())
81+
normal j
82+
call assert_equal(6, winline())
83+
normal j
84+
call assert_equal(8, winline())
85+
normal j
86+
call assert_equal(9, winline())
87+
88+
wincmd w
89+
normal gg
90+
call assert_equal(1, winline())
91+
normal j
92+
call assert_equal(2, winline())
93+
normal j
94+
call assert_equal(4, winline())
95+
normal j
96+
call assert_equal(5, winline())
97+
normal j
98+
call assert_equal(8, winline())
99+
100+
wincmd w
101+
normal gg
102+
call assert_equal(2, winline())
103+
normal j
104+
call assert_equal(3, winline())
105+
normal j
106+
call assert_equal(4, winline())
107+
normal j
108+
call assert_equal(5, winline())
109+
normal j
110+
call assert_equal(6, winline())
111+
normal j
112+
call assert_equal(7, winline())
113+
normal j
114+
call assert_equal(8, winline())
115+
116+
" Test diffoff
117+
diffoff!
118+
1wincmd 2
119+
let &diff = 1
120+
let &fdm = diff_fdm
121+
let &fdc = diff_fdc
122+
4wincmd w
123+
diffoff!
124+
1wincmd w
125+
call assert_equal(0, &diff)
126+
call assert_equal('marker', &foldmethod)
127+
call assert_equal(4, &foldcolumn)
128+
call assert_equal(0, &scrollbind)
129+
call assert_equal(0, &cursorbind)
130+
call assert_equal(1, &wrap)
131+
132+
wincmd w
133+
call assert_equal(0, &diff)
134+
call assert_equal('marker', &foldmethod)
135+
call assert_equal(4, &foldcolumn)
136+
call assert_equal(0, &scrollbind)
137+
call assert_equal(0, &cursorbind)
138+
call assert_equal(1, &wrap)
139+
140+
wincmd w
141+
call assert_equal(0, &diff)
142+
call assert_equal('marker', &foldmethod)
143+
call assert_equal(4, &foldcolumn)
144+
call assert_equal(0, &scrollbind)
145+
call assert_equal(0, &cursorbind)
146+
call assert_equal(1, &wrap)
147+
148+
windo bw!
149+
endfunc
150+
151+
func Test_filler_lines()
152+
" Test that diffing shows correct filler lines
153+
enew!
154+
put =range(4,10)
155+
1d _
156+
vnew
157+
put =range(1,10)
158+
1d _
159+
windo diffthis
160+
wincmd h
161+
call assert_equal(1, line('w0'))
162+
unlet! diff_fdm diff_fdc
163+
164+
windo bw!
165+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2123,
766768
/**/
767769
2122,
768770
/**/

0 commit comments

Comments
 (0)