@@ -974,6 +974,40 @@ describe('API', function()
974
974
eq('hello', nvim('get_option_value', 'makeprg', {}))
975
975
eq('', nvim('get_option_value', 'makeprg', {scope = 'local'}))
976
976
end)
977
+
978
+
it('clears the local value of an option with nil', function()
979
+
-- Set global value
980
+
nvim('set_option_value', 'shiftwidth', 42, {})
981
+
eq(42, nvim('get_option_value', 'shiftwidth', {}))
982
+
983
+
-- Set local value
984
+
nvim('set_option_value', 'shiftwidth', 8, {scope = 'local'})
985
+
eq(8, nvim('get_option_value', 'shiftwidth', {}))
986
+
eq(8, nvim('get_option_value', 'shiftwidth', {scope = 'local'}))
987
+
eq(42, nvim('get_option_value', 'shiftwidth', {scope = 'global'}))
988
+
989
+
-- Clear value without scope
990
+
nvim('set_option_value', 'shiftwidth', NIL, {})
991
+
eq(42, nvim('get_option_value', 'shiftwidth', {}))
992
+
eq(42, nvim('get_option_value', 'shiftwidth', {scope = 'local'}))
993
+
994
+
-- Clear value with explicit scope
995
+
nvim('set_option_value', 'shiftwidth', 8, {scope = 'local'})
996
+
nvim('set_option_value', 'shiftwidth', NIL, {scope = 'local'})
997
+
eq(42, nvim('get_option_value', 'shiftwidth', {}))
998
+
eq(42, nvim('get_option_value', 'shiftwidth', {scope = 'local'}))
999
+
1000
+
-- Now try with options with a special "local is unset" value (e.g. 'undolevels')
1001
+
nvim('set_option_value', 'undolevels', 1000, {})
1002
+
eq(1000, nvim('get_option_value', 'undolevels', {scope = 'local'}))
1003
+
nvim('set_option_value', 'undolevels', NIL, {scope = 'local'})
1004
+
eq(-123456, nvim('get_option_value', 'undolevels', {scope = 'local'}))
1005
+
1006
+
nvim('set_option_value', 'autoread', true, {})
1007
+
eq(true, nvim('get_option_value', 'autoread', {scope = 'local'}))
1008
+
nvim('set_option_value', 'autoread', NIL, {scope = 'local'})
1009
+
eq(NIL, nvim('get_option_value', 'autoread', {scope = 'local'}))
1010
+
end)
977
1011
end)
978
1012
979
1013
describe('nvim_{get,set}_current_buf, nvim_list_bufs', function()
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4