aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_docmd.c8
-rw-r--r--src/nvim/insexpand.c17
-rw-r--r--src/nvim/optionstr.c6
3 files changed, 23 insertions, 8 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 1c215cd3e1..92695aa4de 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -5173,7 +5173,7 @@ static Callback *get_findfunc_callback(void)
return *curbuf->b_p_ffu != NUL ? &curbuf->b_ffu_cb : &ffu_cb;
}
-/// Call 'findfunc' to obtain the list of file names.
+/// Call 'findfunc' to obtain a list of file names.
static list_T *call_findfunc(char *pat, BoolVarValue cmdcomplete)
{
const sctx_T saved_sctx = current_sctx;
@@ -5294,12 +5294,16 @@ const char *did_set_findfunc(optset_T *args)
buf_T *buf = (buf_T *)args->os_buf;
int retval;
- if (*buf->b_p_ffu != NUL) {
+ if (args->os_flags & OPT_LOCAL) {
// buffer-local option set
retval = option_set_callback_func(buf->b_p_ffu, &buf->b_ffu_cb);
} else {
// global option set
retval = option_set_callback_func(p_ffu, &ffu_cb);
+ // when using :set, free the local callback
+ if (!(args->os_flags & OPT_GLOBAL)) {
+ callback_free(&buf->b_ffu_cb);
+ }
}
if (retval == FAIL) {
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 2482cef7a1..c8314d1bb2 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -2368,13 +2368,13 @@ static void copy_global_to_buflocal_cb(Callback *globcb, Callback *bufcb)
/// Invoked when the 'completefunc' option is set. The option value can be a
/// name of a function (string), or function(<name>) or funcref(<name>) or a
/// lambda expression.
-const char *did_set_completefunc(optset_T *args FUNC_ATTR_UNUSED)
+const char *did_set_completefunc(optset_T *args)
{
- if (option_set_callback_func(curbuf->b_p_cfu, &cfu_cb) == FAIL) {
+ buf_T *buf = (buf_T *)args->os_buf;
+ if (option_set_callback_func(buf->b_p_cfu, &cfu_cb) == FAIL) {
return e_invarg;
}
-
- set_buflocal_cfu_callback(curbuf);
+ set_buflocal_cfu_callback(buf);
return NULL;
}
@@ -2412,14 +2412,19 @@ void set_buflocal_ofu_callback(buf_T *buf)
/// lambda expression.
const char *did_set_thesaurusfunc(optset_T *args FUNC_ATTR_UNUSED)
{
+ buf_T *buf = (buf_T *)args->os_buf;
int retval;
- if (*curbuf->b_p_tsrfu != NUL) {
+ if (args->os_flags & OPT_LOCAL) {
// buffer-local option set
- retval = option_set_callback_func(curbuf->b_p_tsrfu, &curbuf->b_tsrfu_cb);
+ retval = option_set_callback_func(buf->b_p_tsrfu, &buf->b_tsrfu_cb);
} else {
// global option set
retval = option_set_callback_func(p_tsrfu, &tsrfu_cb);
+ // when using :set, free the local callback
+ if (!(args->os_flags & OPT_GLOBAL)) {
+ callback_free(&buf->b_tsrfu_cb);
+ }
}
return retval == FAIL ? e_invarg : NULL;
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 307c4ae79f..48423a1779 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -655,6 +655,9 @@ const char *did_set_backupcopy(optset_T *args)
if (opt_flags & OPT_LOCAL) {
bkc = buf->b_p_bkc;
flags = &buf->b_bkc_flags;
+ } else if (!(opt_flags & OPT_GLOBAL)) {
+ // When using :set, clear the local flags.
+ buf->b_bkc_flags = 0;
}
if ((opt_flags & OPT_LOCAL) && *bkc == NUL) {
@@ -1070,6 +1073,9 @@ const char *did_set_completeopt(optset_T *args FUNC_ATTR_UNUSED)
if (args->os_flags & OPT_LOCAL) {
cot = buf->b_p_cot;
flags = &buf->b_cot_flags;
+ } else if (!(args->os_flags & OPT_GLOBAL)) {
+ // When using :set, clear the local flags.
+ buf->b_cot_flags = 0;
}
if (check_opt_strings(cot, p_cot_values, true) != OK) {