Mercurial > vim
comparison src/testdir/test_viminfo.vim @ 7664:1fded31d9e04 v7.4.1131
commit https://github.com/vim/vim/commit/b20e334859334be35de4b295023a2b49bdabbfa9
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jan 18 23:29:01 2016 +0100
patch 7.4.1131
Problem: New lines in the viminfo file are dropped.
Solution: Copy lines starting with "|". Fix that when using :rviminfo in a
function global variables were restored as function-local
variables.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 18 Jan 2016 23:30:05 +0100 |
parents | |
children | fb764adba294 |
comparison
equal
deleted
inserted
replaced
7663:c4b2ec5485e5 | 7664:1fded31d9e04 |
---|---|
1 " Test for reading and writing .viminfo | |
2 | |
3 function Test_read_and_write() | |
4 let lines = [ | |
5 \ '# comment line', | |
6 \ '*encoding=utf-8', | |
7 \ '~MSle0~/asdf', | |
8 \ '|copied as-is', | |
9 \ '|and one more', | |
10 \ ] | |
11 call writefile(lines, 'Xviminfo') | |
12 rviminfo Xviminfo | |
13 call assert_equal('asdf', @/) | |
14 | |
15 wviminfo Xviminfo | |
16 let lines = readfile('Xviminfo') | |
17 let done = 0 | |
18 for line in lines | |
19 if line[0] == '|' | |
20 if done == 0 | |
21 call assert_equal('|copied as-is', line) | |
22 elseif done == 1 | |
23 call assert_equal('|and one more', line) | |
24 endif | |
25 let done += 1 | |
26 endif | |
27 endfor | |
28 call assert_equal(2, done) | |
29 | |
30 call delete('Xviminfo') | |
31 endfunc | |
32 | |
33 func Test_global_vars() | |
34 let test_dict = {'foo': 1, 'bar': 0, 'longvarible': 1000} | |
35 let g:MY_GLOBAL_DICT = test_dict | |
36 " store a really long list, so line wrapping will occur in viminfo file | |
37 let test_list = range(1,100) | |
38 let g:MY_GLOBAL_LIST = test_list | |
39 set viminfo='100,<50,s10,h,! | |
40 wv! Xviminfo | |
41 unlet g:MY_GLOBAL_DICT | |
42 unlet g:MY_GLOBAL_LIST | |
43 | |
44 rv! Xviminfo | |
45 call assert_equal(test_dict, g:MY_GLOBAL_DICT) | |
46 call assert_equal(test_list, g:MY_GLOBAL_LIST) | |
47 | |
48 call delete('Xviminfo') | |
49 set viminfo-=! | |
50 endfunc |