diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-06-25 11:09:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-25 11:09:55 +0200 |
commit | 88a5941598f706f447c92137521fcaf9137920fc (patch) | |
tree | b1d7beb32dabcd9890bcfdd1c7187f2c304e70fc /src/nvim/api/options.c | |
parent | 35e89bf9036b755ae14ee87712faf005886f04f0 (diff) | |
parent | d23465534a8ba5dac1758ffebdc7746138ee5210 (diff) | |
download | rneovim-88a5941598f706f447c92137521fcaf9137920fc.tar.gz rneovim-88a5941598f706f447c92137521fcaf9137920fc.tar.bz2 rneovim-88a5941598f706f447c92137521fcaf9137920fc.zip |
Merge pull request #19041 from lewis6991/globallocal
fix(api): nvim_set_option_value for global-local options
Diffstat (limited to 'src/nvim/api/options.c')
-rw-r--r-- | src/nvim/api/options.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index 19ce25f676..8c174fc129 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -162,6 +162,19 @@ void nvim_set_option_value(String name, Object value, Dict(option) *opts, Error return; } + // If: + // - window id is provided + // - scope is not provided + // - option is global or local to window (global-local) + // + // Then force scope to local since we don't want to change the global option + if (opt_type == SREQ_WIN && scope == 0) { + int flags = get_option_value_strict(name.data, NULL, NULL, opt_type, to); + if (flags & SOPT_GLOBAL) { + scope = OPT_LOCAL; + } + } + long numval = 0; char *stringval = NULL; @@ -460,11 +473,12 @@ void set_option_to(uint64_t channel_id, void *to, int type, String name, Object stringval = value.data.string.data; } - WITH_SCRIPT_CONTEXT(channel_id, { - const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL)) - ? 0 : (type == SREQ_GLOBAL) - ? OPT_GLOBAL : OPT_LOCAL; + // For global-win-local options -> setlocal + // For win-local options -> setglobal and setlocal (opt_flags == 0) + const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL)) ? 0 : + (type == SREQ_GLOBAL) ? OPT_GLOBAL : OPT_LOCAL; + WITH_SCRIPT_CONTEXT(channel_id, { access_option_value_for(name.data, &numval, &stringval, opt_flags, type, to, false, err); }); } |