1
0
forked from aniani/vim

patch 8.2.0084: complete item "user_data" can only be a string

Problem:    Complete item "user_data" can only be a string.
Solution:   Accept any type of variable. (closes #5412)
This commit is contained in:
Bram Moolenaar
2020-01-04 14:32:48 +01:00
parent 5cb0b93d52
commit 0892832bb6
7 changed files with 98 additions and 43 deletions

View File

@@ -447,6 +447,27 @@ dict_add_list(dict_T *d, char *key, list_T *list)
return OK;
}
/*
* Add a typval_T entry to dictionary "d".
* Returns FAIL when out of memory and when key already exists.
*/
int
dict_add_tv(dict_T *d, char *key, typval_T *tv)
{
dictitem_T *item;
item = dictitem_alloc((char_u *)key);
if (item == NULL)
return FAIL;
copy_tv(tv, &item->di_tv);
if (dict_add(d, item) == FAIL)
{
dictitem_free(item);
return FAIL;
}
return OK;
}
/*
* Add a callback to dictionary "d".
* Returns FAIL when out of memory and when key already exists.
@@ -589,6 +610,23 @@ dict_find(dict_T *d, char_u *key, int len)
return HI2DI(hi);
}
/*
* Get a typval_T item from a dictionary and copy it into "rettv".
* Returns FAIL if the entry doesn't exist or out of memory.
*/
int
dict_get_tv(dict_T *d, char_u *key, typval_T *rettv)
{
dictitem_T *di;
char_u *s;
di = dict_find(d, key, -1);
if (di == NULL)
return FAIL;
copy_tv(&di->di_tv, rettv);
return OK;
}
/*
* Get a string item from a dictionary.
* When "save" is TRUE allocate memory for it.
@@ -745,7 +783,7 @@ get_literal_key(char_u **arg, typval_T *tv)
* Return OK or FAIL. Returns NOTDONE for {expr}.
*/
int
dict_get_tv(char_u **arg, typval_T *rettv, int evaluate, int literal)
eval_dict(char_u **arg, typval_T *rettv, int evaluate, int literal)
{
dict_T *d = NULL;
typval_T tvkey;