diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-12-16 18:27:02 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-12-16 18:27:02 +0100 |
commit | 7e1652c63c96585b9e2235c195a3c322b1f11595 (patch) | |
tree | ed90a314ef58909b1c9dfbd45422f1a3557de278 /src/dict.c | |
parent | 6621605eb97cf5fbc481282fd4d349a76e168f16 (diff) | |
download | vim-git-7e1652c63c96585b9e2235c195a3c322b1f11595.tar.gz |
patch 8.0.1394: cannot intercept a yank commandv8.0.1394
Problem: Cannot intercept a yank command.
Solution: Add the TextYankPost autocommand event. (Philippe Vaucher et al.,
closes #2333)
Diffstat (limited to 'src/dict.c')
-rw-r--r-- | src/dict.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/dict.c b/src/dict.c index c13e7a45f..55069783f 100644 --- a/src/dict.c +++ b/src/dict.c @@ -47,6 +47,16 @@ dict_alloc(void) return d; } + dict_T * +dict_alloc_lock(int lock) +{ + dict_T *d = dict_alloc(); + + if (d != NULL) + d->dv_lock = lock; + return d; +} + /* * Allocate an empty dict for a return value. * Returns OK or FAIL. @@ -54,13 +64,12 @@ dict_alloc(void) int rettv_dict_alloc(typval_T *rettv) { - dict_T *d = dict_alloc(); + dict_T *d = dict_alloc_lock(0); if (d == NULL) return FAIL; rettv_dict_set(rettv, d); - rettv->v_lock = 0; return OK; } @@ -80,7 +89,7 @@ rettv_dict_set(typval_T *rettv, dict_T *d) * Free a Dictionary, including all non-container items it contains. * Ignores the reference count. */ - static void + void dict_free_contents(dict_T *d) { int todo; @@ -102,6 +111,8 @@ dict_free_contents(dict_T *d) --todo; } } + + /* The hashtab is still locked, it has to be re-initialized anyway */ hash_clear(&d->dv_hashtab); } @@ -846,4 +857,23 @@ dict_list(typval_T *argvars, typval_T *rettv, int what) } } +/* + * Make each item in the dict readonly (not the value of the item). + */ + void +dict_set_items_ro(dict_T *di) +{ + int todo = (int)di->dv_hashtab.ht_used; + hashitem_T *hi; + + /* Set readonly */ + for (hi = di->dv_hashtab.ht_array; todo > 0 ; ++hi) + { + if (HASHITEM_EMPTY(hi)) + continue; + --todo; + HI2DI(hi)->di_flags |= DI_FLAGS_RO | DI_FLAGS_FIX; + } +} + #endif /* defined(FEAT_EVAL) */ |