aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-20 06:12:02 +0800
committerGitHub <noreply@github.com>2022-08-20 06:12:02 +0800
commite8618df7f826d2ca4d524f12fc712d7c52ea158c (patch)
tree4b1e84ade34a61efbaae47a356eee62bd02145a9 /src/nvim/ops.c
parentebd57209018ed310836a8196ed4710e64a6d8ee5 (diff)
downloadrneovim-e8618df7f826d2ca4d524f12fc712d7c52ea158c.tar.gz
rneovim-e8618df7f826d2ca4d524f12fc712d7c52ea158c.tar.bz2
rneovim-e8618df7f826d2ca4d524f12fc712d7c52ea158c.zip
vim-patch:8.2.3619: cannot use a lambda for 'operatorfunc' (#19846)
Problem: Cannot use a lambda for 'operatorfunc'. Solution: Support using a lambda or partial. (Yegappan Lakshmanan, closes vim/vim#8775) https://github.com/vim/vim/commit/777175b0df8c5ec3cd30d19a2e887e661ac209c8 Omit duplicate docs. It's removed in patch 8.2.3623. Nvim doesn't seem to need callback_set() as it was omitted when patch 8.1.1437 was first ported.
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index c3edc5b315..b4fc7534bc 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -6136,6 +6136,23 @@ static void op_colon(oparg_T *oap)
// do_cmdline() does the rest
}
+/// callback function for 'operatorfunc'
+static Callback opfunc_cb;
+
+/// Process the 'operatorfunc' option value.
+/// @return OK or FAIL
+int set_operatorfunc_option(void)
+{
+ return option_set_callback_func(p_opfunc, &opfunc_cb);
+}
+
+#if defined(EXITFREE)
+void free_operatorfunc_option(void)
+{
+ callback_free(&opfunc_cb);
+}
+#endif
+
/// Handle the "g@" operator: call 'operatorfunc'.
static void op_function(const oparg_T *oap)
FUNC_ATTR_NONNULL_ALL
@@ -6173,7 +6190,10 @@ static void op_function(const oparg_T *oap)
// Reset finish_op so that mode() returns the right value.
finish_op = false;
- (void)call_func_retnr((char *)p_opfunc, 1, argv);
+ typval_T rettv;
+ if (callback_call(&opfunc_cb, 1, argv, &rettv) != FAIL) {
+ tv_clear(&rettv);
+ }
virtual_op = save_virtual_op;
finish_op = save_finish_op;