1
0
forked from aniani/vim

updated for version 7.3.030

Problem:    Cannot store Dict and List in viminfo file.
Solution:   Add support for this. (Christian Brabandt)
This commit is contained in:
Bram Moolenaar
2010-10-20 17:44:42 +02:00
parent f75d498844
commit 680eeca955
12 changed files with 88 additions and 16 deletions

View File

@@ -7530,8 +7530,9 @@ A jump table for the options with a short description can be found at |Q_op|.
! When included, save and restore global variables that start
with an uppercase letter, and don't contain a lowercase
letter. Thus "KEEPTHIS and "K_L_M" are stored, but "KeepThis"
and "_K_L_M" are not. Only String and Number types are
stored.
and "_K_L_M" are not. Nested List and Dict items may not be
read back correctly, you end up with a string representation
instead.
" Maximum number of lines saved for each register. Old name of
the '<' item, with the disadvantage that you need to put a
backslash before the ", otherwise it will be recognized as the

View File

@@ -22520,18 +22520,21 @@ read_viminfo_varlist(virp, writing)
if (tab != NULL)
{
*tab++ = '\0'; /* isolate the variable name */
if (*tab == 'S') /* string var */
type = VAR_STRING;
switch (*tab)
{
case 'S': type = VAR_STRING; break;
#ifdef FEAT_FLOAT
else if (*tab == 'F')
type = VAR_FLOAT;
case 'F': type = VAR_FLOAT; break;
#endif
case 'D': type = VAR_DICT; break;
case 'L': type = VAR_LIST; break;
}
tab = vim_strchr(tab, '\t');
if (tab != NULL)
{
tv.v_type = type;
if (type == VAR_STRING)
if (type == VAR_STRING || type == VAR_DICT || type == VAR_LIST)
tv.vval.v_string = viminfo_readstring(virp,
(int)(tab - virp->vir_line + 1), TRUE);
#ifdef FEAT_FLOAT
@@ -22540,9 +22543,27 @@ read_viminfo_varlist(virp, writing)
#endif
else
tv.vval.v_number = atol((char *)tab + 1);
set_var(virp->vir_line + 1, &tv, FALSE);
if (type == VAR_STRING)
if (type == VAR_DICT || type == VAR_LIST)
{
typval_T *etv = eval_expr(tv.vval.v_string, NULL);
if (etv == NULL)
/* Failed to parse back the dict or list, use it as a
* string. */
tv.v_type = VAR_STRING;
else
{
vim_free(tv.vval.v_string);
tv = *etv;
}
}
set_var(virp->vir_line + 1, &tv, FALSE);
if (tv.v_type == VAR_STRING)
vim_free(tv.vval.v_string);
else if (tv.v_type == VAR_DICT || tv.v_type == VAR_LIST)
clear_tv(&tv);
}
}
}
@@ -22586,6 +22607,8 @@ write_viminfo_varlist(fp)
#ifdef FEAT_FLOAT
case VAR_FLOAT: s = "FLO"; break;
#endif
case VAR_DICT: s = "DIC"; break;
case VAR_LIST: s = "LIS"; break;
default: continue;
}
fprintf(fp, "!%s\t%s\t", this_var->di_key, s);

View File

@@ -27,7 +27,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test56.out test57.out test58.out test59.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out test70.out \
test71.out test72.out test73.out
test71.out test72.out test73.out test74.out
.SUFFIXES: .in .out
@@ -120,3 +120,4 @@ test70.out: test70.in
test71.out: test71.in
test72.out: test72.in
test73.out: test73.in
test74.out: test74.in

View File

@@ -27,7 +27,8 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test30.out test31.out test32.out test33.out test34.out \
test37.out test38.out test39.out test40.out test41.out \
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out test71.out test72.out test73.out
test68.out test69.out test71.out test72.out test73.out \
test74.out
SCRIPTS32 = test50.out test70.out

View File

@@ -47,7 +47,8 @@ SCRIPTS = test3.out test4.out test5.out test6.out test7.out \
test30.out test31.out test32.out test33.out test34.out \
test37.out test38.out test39.out test40.out test41.out \
test42.out test52.out test65.out test66.out test67.out \
test68.out test69.out test71.out test72.out test72.out
test68.out test69.out test71.out test72.out test73.out \
test74.out
SCRIPTS32 = test50.out test70.out

View File

@@ -27,7 +27,7 @@ SCRIPTS = test1.out test3.out test4.out test5.out test6.out \
test56.out test57.out test58.out test59.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out test70.out \
test71.out test72.out test73.out
test71.out test72.out test73.out test74.out
.SUFFIXES: .in .out

View File

@@ -74,7 +74,7 @@ SCRIPT = test1.out test2.out test3.out test4.out test5.out \
test56.out test57.out test60.out \
test61.out test62.out test63.out test64.out test65.out \
test66.out test67.out test68.out test69.out \
test71.out test72.out
test71.out test72.out test74.out
# Known problems:
# Test 30: a problem around mac format - unknown reason

View File

@@ -10,6 +10,7 @@ VIMPROG = ../vim
# This will make testing about 10 times as slow.
# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --log-file=valgrind.$*
SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test7.out test8.out test9.out test10.out test11.out \
test12.out test13.out test14.out test15.out test17.out \
@@ -23,7 +24,8 @@ SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
test54.out test55.out test56.out test57.out test58.out \
test59.out test60.out test61.out test62.out test63.out \
test64.out test65.out test66.out test67.out test68.out \
test69.out test70.out test71.out test72.out test73.out
test69.out test70.out test71.out test72.out test73.out \
test74.out
SCRIPTS_GUI = test16.out

View File

@@ -13,7 +13,7 @@ Scripts = test1.out test2.out test3.out test4.out test5.out test6.out
test33.out test34.out test35.out test36.out test37.out
test38.out test39.out test40.out test41.out test42.out
test43.out test44.out test45.out test46.out test47.out
test48.out test49.out
test48.out test49.out test74.out
ScriptsGUI = test16.out

36
src/testdir/test74.in Normal file
View File

@@ -0,0 +1,36 @@
" Tests for storing global variables in the .viminfo file vim: set ft=vim:
STARTTEST
:so small.vim
:" Do all test in a separate window to avoid E211 when we recursively
:" delete the Xfind directory during cleanup
:"
:" This will cause a few errors, do it silently.
:set visualbell
:set nocp viminfo+=!,nviminfo
:let MY_GLOBAL_DICT={'foo': 1, 'bar': 0, 'longvarible': 1000}
:" store a really long list, so line wrapping will occur in viminfo file
:let MY_GLOBAL_LIST=range(1,100)
:wv! Xviminfo
:unlet MY_GLOBAL_DICT
:unlet MY_GLOBAL_LIST
:rv! Xviminfo
:call delete('Xviminfo')
:if exists("MY_GLOBAL_DICT")
:redir >> test.out
:echo MY_GLOBAL_DICT
:redir end
:endif
:if exists("MY_GLOBAL_LIST")
:redir >> test.out
:echo MY_GLOBAL_LIST
:redir end
:endif
:redir >> test.out
:echo "foobar"
:redir end
:endif
:qa!
ENDTEST
eof

5
src/testdir/test74.ok Normal file
View File

@@ -0,0 +1,5 @@
{'foo': 1, 'longvarible': 1000, 'bar': 0}
[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]
foobar

View File

@@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
30,
/**/
29,
/**/