patch 8.0.1394: cannot intercept a yank command
Problem: Cannot intercept a yank command.
Solution: Add the TextYankPost autocommand event. (Philippe Vaucher et al.,
closes #2333)
diff --git a/src/eval.c b/src/eval.c
index 1cced57..85f607c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -192,6 +192,7 @@
{VV_NAME("termu7resp", VAR_STRING), VV_RO},
{VV_NAME("termstyleresp", VAR_STRING), VV_RO},
{VV_NAME("termblinkresp", VAR_STRING), VV_RO},
+ {VV_NAME("event", VAR_DICT), VV_RO},
};
/* shorthand */
@@ -319,8 +320,9 @@
set_vim_var_nr(VV_SEARCHFORWARD, 1L);
set_vim_var_nr(VV_HLSEARCH, 1L);
- set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc());
+ set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED));
set_vim_var_list(VV_ERRORS, list_alloc());
+ set_vim_var_dict(VV_EVENT, dict_alloc_lock(VAR_FIXED));
set_vim_var_nr(VV_FALSE, VVAL_FALSE);
set_vim_var_nr(VV_TRUE, VVAL_TRUE);
@@ -6633,6 +6635,16 @@
}
/*
+ * Get Dict v: variable value. Caller must take care of reference count when
+ * needed.
+ */
+ dict_T *
+get_vim_var_dict(int idx)
+{
+ return vimvars[idx].vv_dict;
+}
+
+/*
* Set v:char to character "c".
*/
void
@@ -6706,25 +6718,13 @@
void
set_vim_var_dict(int idx, dict_T *val)
{
- int todo;
- hashitem_T *hi;
-
clear_tv(&vimvars[idx].vv_di.di_tv);
vimvars[idx].vv_type = VAR_DICT;
vimvars[idx].vv_dict = val;
if (val != NULL)
{
++val->dv_refcount;
-
- /* Set readonly */
- todo = (int)val->dv_hashtab.ht_used;
- for (hi = val->dv_hashtab.ht_array; todo > 0 ; ++hi)
- {
- if (HASHITEM_EMPTY(hi))
- continue;
- --todo;
- HI2DI(hi)->di_flags |= DI_FLAGS_RO | DI_FLAGS_FIX;
- }
+ dict_set_items_ro(val);
}
}