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/dict.c b/src/dict.c
index c13e7a4..5506978 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -47,6 +47,16 @@
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 @@
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 @@
* 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 @@
--todo;
}
}
+
+ /* The hashtab is still locked, it has to be re-initialized anyway */
hash_clear(&d->dv_hashtab);
}
@@ -846,4 +857,23 @@
}
}
+/*
+ * 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) */