diff options
Diffstat (limited to 'src/nvim/insexpand.c')
-rw-r--r-- | src/nvim/insexpand.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 1acdddedef..78d820c2a7 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -2233,7 +2233,7 @@ static Callback tsrfu_cb; ///< 'thesaurusfunc' callback function static void copy_global_to_buflocal_cb(Callback *globcb, Callback *bufcb) { callback_free(bufcb); - if (globcb->data.funcref != NULL && *globcb->data.funcref != NUL) { + if (globcb->type != kCallbackNone) { callback_copy(bufcb, globcb); } } @@ -2290,17 +2290,26 @@ int set_thesaurusfunc_option(void) if (*curbuf->b_p_tsrfu != NUL) { // buffer-local option set - callback_free(&curbuf->b_tsrfu_cb); retval = option_set_callback_func(curbuf->b_p_tsrfu, &curbuf->b_tsrfu_cb); } else { // global option set - callback_free(&tsrfu_cb); retval = option_set_callback_func(p_tsrfu, &tsrfu_cb); } return retval; } +/// Mark the global 'completefunc' 'omnifunc' and 'thesaurusfunc' callbacks with +/// "copyID" so that they are not garbage collected. +bool set_ref_in_insexpand_funcs(int copyID) +{ + bool abort = set_ref_in_callback(&cfu_cb, copyID, NULL, NULL); + abort = abort || set_ref_in_callback(&ofu_cb, copyID, NULL, NULL); + abort = abort || set_ref_in_callback(&tsrfu_cb, copyID, NULL, NULL); + + return abort; +} + /// Get the user-defined completion function name for completion "type" static char_u *get_complete_funcname(int type) { |