aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index cd6060b5d2..82c9a1da67 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -184,35 +184,28 @@ Object dict_set_var(dict_T *dict, String key, Object value, bool del,
bool retval, Error *err)
{
Object rv = OBJECT_INIT;
-
- if (dict->dv_lock) {
- api_set_error(err, kErrorTypeException, "Dictionary is locked");
- return rv;
- }
-
- if (key.size == 0) {
- api_set_error(err, kErrorTypeValidation, "Key name is empty");
- return rv;
- }
-
- if (key.size > INT_MAX) {
- api_set_error(err, kErrorTypeValidation, "Key name is too long");
- return rv;
- }
-
dictitem_T *di = tv_dict_find(dict, key.data, (ptrdiff_t)key.size);
if (di != NULL) {
if (di->di_flags & DI_FLAGS_RO) {
api_set_error(err, kErrorTypeException, "Key is read-only: %s", key.data);
return rv;
- } else if (di->di_flags & DI_FLAGS_FIX) {
- api_set_error(err, kErrorTypeException, "Key is fixed: %s", key.data);
- return rv;
} else if (di->di_flags & DI_FLAGS_LOCK) {
api_set_error(err, kErrorTypeException, "Key is locked: %s", key.data);
return rv;
+ } else if (del && (di->di_flags & DI_FLAGS_FIX)) {
+ api_set_error(err, kErrorTypeException, "Key is fixed: %s", key.data);
+ return rv;
}
+ } else if (dict->dv_lock) {
+ api_set_error(err, kErrorTypeException, "Dictionary is locked");
+ return rv;
+ } else if (key.size == 0) {
+ api_set_error(err, kErrorTypeValidation, "Key name is empty");
+ return rv;
+ } else if (key.size > INT_MAX) {
+ api_set_error(err, kErrorTypeValidation, "Key name is too long");
+ return rv;
}
if (del) {