test: don't unnecessarily specify win/buf for nvim_(get|set)_option_value

`nvim_(get|set)_option_value` pick the current buffer / window by default for buffer-local/window-local (but not global-local) options. So specifying `buf = 0` or `win = 0` in opts is unnecessary for those options. This PR removes those to reduce code clutter.
This commit is contained in:
Famiu Haque
2023-05-22 12:47:10 +06:00
parent 8b8e607284
commit 576dddb461
22 changed files with 76 additions and 76 deletions

View File

@@ -630,19 +630,19 @@ describe('api/buf', function()
eq('Index out of bounds', pcall_err(get_offset, 6))
eq('Index out of bounds', pcall_err(get_offset, -1))
meths.set_option_value('eol', false, {buf=0})
meths.set_option_value('fixeol', false, {buf=0})
meths.set_option_value('eol', false, {})
meths.set_option_value('fixeol', false, {})
eq(28, get_offset(5))
-- fileformat is ignored
meths.set_option_value('fileformat', 'dos', {buf=0})
meths.set_option_value('fileformat', 'dos', {})
eq(0, get_offset(0))
eq(6, get_offset(1))
eq(15, get_offset(2))
eq(16, get_offset(3))
eq(24, get_offset(4))
eq(28, get_offset(5))
meths.set_option_value('eol', true, {buf=0})
meths.set_option_value('eol', true, {})
eq(29, get_offset(5))
command("set hidden")
@@ -699,9 +699,9 @@ describe('api/buf', function()
describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
eq(8, nvim('get_option_value', 'shiftwidth', {buf = 0}))
nvim('set_option_value', 'shiftwidth', 4, {buf=0})
eq(4, nvim('get_option_value', 'shiftwidth', {buf = 0}))
eq(8, nvim('get_option_value', 'shiftwidth', {}))
nvim('set_option_value', 'shiftwidth', 4, {})
eq(4, nvim('get_option_value', 'shiftwidth', {}))
-- global-local option
nvim('set_option_value', 'define', 'test', {buf = 0})
eq('test', nvim('get_option_value', 'define', {buf = 0}))

View File

@@ -1401,7 +1401,7 @@ describe('API/extmarks', function()
it('in read-only buffer', function()
command("view! runtime/doc/help.txt")
eq(true, meths.get_option_value('ro', {buf=0}))
eq(true, meths.get_option_value('ro', {}))
local id = set_extmark(ns, 0, 0, 2)
eq({{id, 0, 2}}, get_extmarks(ns,0, -1))
end)
@@ -1474,7 +1474,7 @@ describe('API/extmarks', function()
it('in prompt buffer', function()
feed('dd')
local id = set_extmark(ns, marks[1], 0, 0, {})
meths.set_option_value('buftype', 'prompt', {buf = 0})
meths.set_option_value('buftype', 'prompt', {})
feed('i<esc>')
eq({{id, 0, 2}}, get_extmarks(ns, 0, -1))
end)

View File

@@ -1397,7 +1397,7 @@ describe('API', function()
it('works to set global value of local options', function()
nvim('set_option_value', 'lisp', true, {scope='global'})
eq(true, nvim('get_option_value', 'lisp', {scope='global'}))
eq(false, nvim('get_option_value', 'lisp', {buf=0}))
eq(false, nvim('get_option_value', 'lisp', {}))
eq(nil, nvim('command_output', 'setglobal lisp?'):match('nolisp'))
eq('nolisp', nvim('command_output', 'setlocal lisp?'):match('nolisp'))
nvim('set_option_value', 'shiftwidth', 20, {scope='global'})
@@ -1493,7 +1493,7 @@ describe('API', function()
end)
it('set window options', function()
nvim('set_option_value', 'colorcolumn', '4,3', {win=0})
nvim('set_option_value', 'colorcolumn', '4,3', {})
eq('4,3', nvim('get_option_value', 'colorcolumn', {scope = 'local'}))
command("set modified hidden")
command("enew") -- edit new buffer, window option is preserved

View File

@@ -365,11 +365,11 @@ describe('API/win', function()
describe('nvim_get_option_value, nvim_set_option_value', function()
it('works', function()
nvim('set_option_value', 'colorcolumn', '4,3', {win=0})
eq('4,3', nvim('get_option_value', 'colorcolumn', {win = 0}))
nvim('set_option_value', 'colorcolumn', '4,3', {})
eq('4,3', nvim('get_option_value', 'colorcolumn', {}))
command("set modified hidden")
command("enew") -- edit new buffer, window option is preserved
eq('4,3', nvim('get_option_value', 'colorcolumn', {win = 0}))
eq('4,3', nvim('get_option_value', 'colorcolumn', {}))
-- global-local option
nvim('set_option_value', 'statusline', 'window-status', {win=0})