mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: Add test cases to legacy test autocmd_option
This commit is contained in:
parent
b535df1554
commit
9bd8fcde1e
@ -2,6 +2,8 @@ local helpers = require('test.functional.helpers')
|
||||
local nvim = helpers.meths
|
||||
local clear, eq, neq = helpers.clear, helpers.eq, helpers.neq
|
||||
local curbuf, buf = helpers.curbuf, helpers.bufmeths
|
||||
local curwin, win = helpers.curwin, helpers.winmeths
|
||||
local redir_exec = helpers.redir_exec
|
||||
local source, execute = helpers.source, helpers.execute
|
||||
|
||||
local function declare_hook_function()
|
||||
@ -86,7 +88,7 @@ end
|
||||
|
||||
local function make_buffer()
|
||||
local old_buf = curbuf()
|
||||
execute('new')
|
||||
execute('botright new')
|
||||
local new_buf = curbuf()
|
||||
execute('wincmd p') -- move previous window
|
||||
|
||||
@ -96,6 +98,19 @@ local function make_buffer()
|
||||
return new_buf
|
||||
end
|
||||
|
||||
local function make_window_with_winnr()
|
||||
local old_win = curwin()
|
||||
execute('botright new')
|
||||
local new_win = curwin()
|
||||
local new_winnr = redir_exec('echo winnr()')
|
||||
execute('wincmd p') -- move previous window
|
||||
|
||||
neq(old_win, new_win)
|
||||
eq(old_win, curwin())
|
||||
|
||||
return new_win, new_winnr:gsub('\n', '')
|
||||
end
|
||||
|
||||
describe('au OptionSet', function()
|
||||
describe('with any opton (*)', function()
|
||||
|
||||
@ -248,6 +263,32 @@ describe('au OptionSet', function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('being set by setwinvar()', function()
|
||||
it('should not trigger because option name does not match with backup', function()
|
||||
set_hook('backup')
|
||||
|
||||
execute('call setwinvar(1, "&l:bk", 1)')
|
||||
expected_empty()
|
||||
end)
|
||||
|
||||
it('should trigger, use correct option name backup', function()
|
||||
set_hook('backup')
|
||||
|
||||
execute('call setwinvar(1, "&backup", 1)')
|
||||
expected_combination({'backup', 0, 1, 'local'})
|
||||
end)
|
||||
|
||||
it('should not trigger if the current window is different from the targetted window', function()
|
||||
set_hook('cursorcolumn')
|
||||
|
||||
local new_window, new_winnr = make_window_with_winnr()
|
||||
|
||||
execute('call setwinvar(' .. new_winnr .. ', "&cursorcolumn", 1)')
|
||||
-- expected_combination({'cursorcolumn', 0, 1, 'local', {winnr = new_winnr}})
|
||||
expected_empty()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('being set by neovim api', function()
|
||||
it('should trigger if a boolean option be set globally', function()
|
||||
set_hook('autochdir')
|
||||
|
Loading…
Reference in New Issue
Block a user