mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
api: Rename dict_set_value to dict_set_var
Reasonings: 1. It is not used for anything, but scope dictionaries currenly. So there is no need to generalize and split it into dict_set_var (which will contain some scope-dictionary-specific checks) and dict_set_value (which will work for any dictionary). 2. Check for key size is no longer valid for non-scope dictionaries: you *can* use empty keys there. In scope dictionaries also, but you actually are not supposed to store there anything, but variables. Note that actually one may still do let b:[''] = 1 and “bypass” check for variable name. It won’t change what `echo b:` will show, but it may affect code which iterates over scope dictionary keys and sets them to something (if there is such code).
This commit is contained in:
@@ -98,7 +98,7 @@ Object dict_get_value(dict_T *dict, String key, Error *err)
|
||||
return vim_to_object(&di->di_tv);
|
||||
}
|
||||
|
||||
/// Set a value in a dict. Objects are recursively expanded into their
|
||||
/// Set a value in a scope dict. Objects are recursively expanded into their
|
||||
/// vimscript equivalents.
|
||||
///
|
||||
/// @param dict The vimscript dict
|
||||
@@ -109,8 +109,8 @@ Object dict_get_value(dict_T *dict, String key, Error *err)
|
||||
/// @param retval If true the old value will be converted and returned.
|
||||
/// @param[out] err Details of an error that may have occurred
|
||||
/// @return The old value if `retval` is true and the key was present, else NIL
|
||||
Object dict_set_value(dict_T *dict, String key, Object value, bool del,
|
||||
bool retval, Error *err)
|
||||
Object dict_set_var(dict_T *dict, String key, Object value, bool del,
|
||||
bool retval, Error *err)
|
||||
{
|
||||
Object rv = OBJECT_INIT;
|
||||
|
||||
@@ -120,7 +120,7 @@ Object dict_set_value(dict_T *dict, String key, Object value, bool del,
|
||||
}
|
||||
|
||||
if (key.size == 0) {
|
||||
api_set_error(err, Validation, _("Empty dictionary keys aren't allowed"));
|
||||
api_set_error(err, Validation, _("Empty variable names aren't allowed"));
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ Object dict_set_value(dict_T *dict, String key, Object value, bool del,
|
||||
return rv;
|
||||
}
|
||||
|
||||
dictitem_T *di = dict_find(dict, (uint8_t *)key.data, (int)key.size);
|
||||
dictitem_T *di = dict_find(dict, (char_u *)key.data, (int)key.size);
|
||||
|
||||
if (del) {
|
||||
// Delete the key
|
||||
|
Reference in New Issue
Block a user