aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-02-27 10:29:46 +0100
committerGitHub <noreply@github.com>2017-02-27 10:29:46 +0100
commitc318d8e672a3b1dfe4ba7954dbca61c509c2b99c (patch)
tree282a6090dbf2d9017a3ad0a7382df08b2d320a05 /src/nvim/api/private/helpers.c
parent8c8ce1832e780f87b2922ba3acf0d44f78c50931 (diff)
parenta85021068de95ef7c69b3b93b31bc32fbb154ed3 (diff)
downloadrneovim-c318d8e672a3b1dfe4ba7954dbca61c509c2b99c.tar.gz
rneovim-c318d8e672a3b1dfe4ba7954dbca61c509c2b99c.tar.bz2
rneovim-c318d8e672a3b1dfe4ba7954dbca61c509c2b99c.zip
Merge #6112 from ZyX-I/split-eval'/buf_get_changedtick
Better b:changedtick support
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index ba4d005e9a..7efa086af2 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -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,20 @@ 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 (di != NULL) {
+ if (di->di_flags & DI_FLAGS_RO) {
+ api_set_error(err, Exception, _("Key is read-only: %s"), key.data);
+ return rv;
+ } else if (di->di_flags & DI_FLAGS_FIX) {
+ api_set_error(err, Exception, _("Key is fixed: %s"), key.data);
+ return rv;
+ } else if (di->di_flags & DI_FLAGS_LOCK) {
+ api_set_error(err, Exception, _("Key is locked: %s"), key.data);
+ return rv;
+ }
+ }
if (del) {
// Delete the key