diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2021-12-21 14:20:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-21 14:20:34 -0700 |
commit | 33cd1ba00ad4483aa2d7cb386e7204737f8936fe (patch) | |
tree | 0e8d112f80521aaca152d95d982a684b3e4a6979 /src/nvim/api/vim.c | |
parent | 1b04da52b3ce611e06b7d1c87af4a71c37ad127a (diff) | |
download | rneovim-33cd1ba00ad4483aa2d7cb386e7204737f8936fe.tar.gz rneovim-33cd1ba00ad4483aa2d7cb386e7204737f8936fe.tar.bz2 rneovim-33cd1ba00ad4483aa2d7cb386e7204737f8936fe.zip |
fix(api): make nil value in nvim_set_option_value clear local value (#16710)
For special options such as 'undolevels' and 'scrolloff', this sets the
local value to the special "unset" value (e.g. -12345 for 'undolevels').
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 4f7c320129..f81cdf9deb 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -696,7 +696,17 @@ Object nvim_get_option_value(String name, Dict(option) *opts, Error *err) rv = INTEGER_OBJ(numval); break; case 2: - rv = BOOLEAN_OBJ(!!numval); + switch (numval) { + case 0: + case 1: + rv = BOOLEAN_OBJ(numval); + break; + default: + // Boolean options that return something other than 0 or 1 should return nil. Currently this + // only applies to 'autoread' which uses -1 as a local value to indicate "unset" + rv = NIL; + break; + } break; default: api_set_error(err, kErrorTypeValidation, "unknown option '%s'", name.data); @@ -749,7 +759,7 @@ void nvim_set_option_value(String name, Object value, Dict(option) *opts, Error stringval = value.data.string.data; break; case kObjectTypeNil: - // Do nothing + scope |= OPT_CLEAR; break; default: api_set_error(err, kErrorTypeValidation, "invalid value for option"); |