aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/vim_spec.lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2021-12-21 14:20:34 -0700
committerGitHub <noreply@github.com>2021-12-21 14:20:34 -0700
commit33cd1ba00ad4483aa2d7cb386e7204737f8936fe (patch)
tree0e8d112f80521aaca152d95d982a684b3e4a6979 /test/functional/api/vim_spec.lua
parent1b04da52b3ce611e06b7d1c87af4a71c37ad127a (diff)
downloadrneovim-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 'test/functional/api/vim_spec.lua')
-rw-r--r--test/functional/api/vim_spec.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index d53208a915..112adfaf2d 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -974,6 +974,40 @@ describe('API', function()
eq('hello', nvim('get_option_value', 'makeprg', {}))
eq('', nvim('get_option_value', 'makeprg', {scope = 'local'}))
end)
+
+ it('clears the local value of an option with nil', function()
+ -- Set global value
+ nvim('set_option_value', 'shiftwidth', 42, {})
+ eq(42, nvim('get_option_value', 'shiftwidth', {}))
+
+ -- Set local value
+ nvim('set_option_value', 'shiftwidth', 8, {scope = 'local'})
+ eq(8, nvim('get_option_value', 'shiftwidth', {}))
+ eq(8, nvim('get_option_value', 'shiftwidth', {scope = 'local'}))
+ eq(42, nvim('get_option_value', 'shiftwidth', {scope = 'global'}))
+
+ -- Clear value without scope
+ nvim('set_option_value', 'shiftwidth', NIL, {})
+ eq(42, nvim('get_option_value', 'shiftwidth', {}))
+ eq(42, nvim('get_option_value', 'shiftwidth', {scope = 'local'}))
+
+ -- Clear value with explicit scope
+ nvim('set_option_value', 'shiftwidth', 8, {scope = 'local'})
+ nvim('set_option_value', 'shiftwidth', NIL, {scope = 'local'})
+ eq(42, nvim('get_option_value', 'shiftwidth', {}))
+ eq(42, nvim('get_option_value', 'shiftwidth', {scope = 'local'}))
+
+ -- Now try with options with a special "local is unset" value (e.g. 'undolevels')
+ nvim('set_option_value', 'undolevels', 1000, {})
+ eq(1000, nvim('get_option_value', 'undolevels', {scope = 'local'}))
+ nvim('set_option_value', 'undolevels', NIL, {scope = 'local'})
+ eq(-123456, nvim('get_option_value', 'undolevels', {scope = 'local'}))
+
+ nvim('set_option_value', 'autoread', true, {})
+ eq(true, nvim('get_option_value', 'autoread', {scope = 'local'}))
+ nvim('set_option_value', 'autoread', NIL, {scope = 'local'})
+ eq(NIL, nvim('get_option_value', 'autoread', {scope = 'local'}))
+ end)
end)
describe('nvim_{get,set}_current_buf, nvim_list_bufs', function()