1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
" 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)
call delete('Xtest')
call delete('Xtest2')
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 diffoff
bwipe!
enew!
endfunc
func Test_diffget_diffput()
enew!
let l = range(50)
call setline(1, l)
call assert_fails('diffget', 'E99:')
diffthis
call assert_fails('diffget', 'E100:')
new
let l[10] = 'one'
let l[20] = 'two'
let l[30] = 'three'
let l[40] = 'four'
call setline(1, l)
diffthis
call assert_equal('one', getline(11))
11diffget
call assert_equal('10', getline(11))
21diffput
wincmd w
call assert_equal('two', getline(21))
normal 31Gdo
call assert_equal('three', getline(31))
call assert_equal('40', getline(41))
normal 41Gdp
wincmd w
call assert_equal('40', getline(41))
new
diffthis
call assert_fails('diffget', 'E101:')
windo diffoff
bwipe!
bwipe!
enew!
endfunc
|