comparison src/testdir/test_viminfo.vim @ 9284:78712a2f687a v7.4.1925

commit https://github.com/vim/vim/commit/2d35899721da0e9359a9fe1059554f8c4ea7f0c1 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 12 21:20:54 2016 +0200 patch 7.4.1925 Problem: Viminfo does not merge file marks properly. Solution: Use a timestamp. Add the :clearjumps command.
author Christian Brabandt <cb@256bit.org>
date Sun, 12 Jun 2016 21:30:06 +0200
parents 083113d751ff
children 8000f0a44744
comparison
equal deleted inserted replaced
9283:0b359cb19c27 9284:78712a2f687a
15 15
16 wviminfo Xviminfo 16 wviminfo Xviminfo
17 let lines = readfile('Xviminfo') 17 let lines = readfile('Xviminfo')
18 let done = 0 18 let done = 0
19 for line in lines 19 for line in lines
20 if line[0] == '|' && line !~ '^|3,' 20 if line[0] == '|' && line !~ '^|[234],'
21 if done == 0 21 if done == 0
22 call assert_equal('|1,3', line) 22 call assert_equal('|1,4', line)
23 elseif done == 1 23 elseif done == 1
24 call assert_equal('|copied as-is', line) 24 call assert_equal('|copied as-is', line)
25 elseif done == 2 25 elseif done == 2
26 call assert_equal('|and one more', line) 26 call assert_equal('|and one more', line)
27 endif 27 endif
215 call assert_equal("V", getregtype('d')) 215 call assert_equal("V", getregtype('d'))
216 216
217 call delete('Xviminfo') 217 call delete('Xviminfo')
218 endfunc 218 endfunc
219 219
220 func Test_viminfo_marks()
221 sp bufa
222 let bufa = bufnr('%')
223 sp bufb
224 let bufb = bufnr('%')
225
226 call test_settime(8)
227 call setpos("'A", [bufa, 1, 1, 0])
228 call test_settime(20)
229 call setpos("'B", [bufb, 9, 1, 0])
230 call setpos("'C", [bufa, 7, 1, 0])
231
232 delmark 0-9
233 call test_settime(25)
234 call setpos("'1", [bufb, 12, 1, 0])
235 call test_settime(35)
236 call setpos("'0", [bufa, 11, 1, 0])
237
238 call test_settime(45)
239 wviminfo Xviminfo
240
241 " Writing viminfo inserts the '0 mark.
242 call assert_equal([bufb, 1, 1, 0], getpos("'0"))
243 call assert_equal([bufa, 11, 1, 0], getpos("'1"))
244 call assert_equal([bufb, 12, 1, 0], getpos("'2"))
245
246 call test_settime(4)
247 call setpos("'A", [bufa, 9, 1, 0])
248 call test_settime(30)
249 call setpos("'B", [bufb, 2, 3, 0])
250 delmark C
251
252 delmark 0-9
253 call test_settime(30)
254 call setpos("'1", [bufb, 22, 1, 0])
255 call test_settime(55)
256 call setpos("'0", [bufa, 21, 1, 0])
257
258 rviminfo Xviminfo
259
260 call assert_equal([bufa, 1, 1, 0], getpos("'A"))
261 call assert_equal([bufb, 2, 3, 0], getpos("'B"))
262 call assert_equal([bufa, 7, 1, 0], getpos("'C"))
263
264 " numbered marks are merged
265 call assert_equal([bufa, 21, 1, 0], getpos("'0")) " time 55
266 call assert_equal([bufb, 1, 1, 0], getpos("'1")) " time 45
267 call assert_equal([bufa, 11, 1, 0], getpos("'2")) " time 35
268 call assert_equal([bufb, 22, 1, 0], getpos("'3")) " time 30
269 call assert_equal([bufb, 12, 1, 0], getpos("'4")) " time 25
270
271 call delete('Xviminfo')
272 exe 'bwipe ' . bufa
273 exe 'bwipe ' . bufb
274 endfunc
275
276 func Test_viminfo_jumplist()
277 split testbuf
278 clearjumps
279 call setline(1, ['time 05', 'time 10', 'time 15', 'time 20', 'time 30', 'last pos'])
280 call cursor(2, 1)
281 call test_settime(10)
282 exe "normal /20\r"
283 call test_settime(20)
284 exe "normal /30\r"
285 call test_settime(30)
286 exe "normal /last pos\r"
287 wviminfo Xviminfo
288
289 clearjumps
290 call cursor(1, 1)
291 call test_settime(5)
292 exe "normal /15\r"
293 call test_settime(15)
294 exe "normal /last pos\r"
295 call test_settime(40)
296 exe "normal ?30\r"
297 rviminfo Xviminfo
298
299 call assert_equal('time 30', getline('.'))
300 exe "normal \<C-O>"
301 call assert_equal('last pos', getline('.'))
302 exe "normal \<C-O>"
303 " duplicate for 'time 30' was removed
304 call assert_equal('time 20', getline('.'))
305 exe "normal \<C-O>"
306 call assert_equal('time 15', getline('.'))
307 exe "normal \<C-O>"
308 call assert_equal('time 10', getline('.'))
309 exe "normal \<C-O>"
310 call assert_equal('time 05', getline('.'))
311
312 bwipe!
313 call delete('Xviminfo')
314 endfunc
315
220 func Test_viminfo_encoding() 316 func Test_viminfo_encoding()
221 if !has('multi_byte') 317 if !has('multi_byte')
222 return 318 return
223 endif 319 endif
224 set enc=latin1 320 set enc=latin1