Mercurial > vim
diff src/dict.c @ 19047:a3fce2763e83 v8.2.0084
patch 8.2.0084: complete item "user_data" can only be a string
Commit: https://github.com/vim/vim/commit/0892832bb6c7e322fcae8560eaad5a8140ee4a06
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 4 14:32:48 2020 +0100
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 https://github.com/vim/vim/issues/5412)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 04 Jan 2020 14:45:04 +0100 |
parents | 3a68dc2a1bc1 |
children | c6248ef5b41b |
line wrap: on
line diff
--- a/src/dict.c +++ b/src/dict.c @@ -448,6 +448,27 @@ dict_add_list(dict_T *d, char *key, list } /* + * 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. */ @@ -590,6 +611,23 @@ dict_find(dict_T *d, char_u *key, int le } /* + * 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. * When FALSE a shared buffer is used, can only be used once! @@ -745,7 +783,7 @@ get_literal_key(char_u **arg, typval_T * * 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;