mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
test(tui_spec): use RPC request to setup autocommands
This avoids changing cmdline and fixes a warning.
This commit is contained in:
@@ -109,14 +109,14 @@ describe('TUI', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('accepts resize while pager is active', function()
|
it('accepts resize while pager is active', function()
|
||||||
child_session:request("nvim_command", [[
|
child_session:request("nvim_exec", [[
|
||||||
set more
|
set more
|
||||||
func! ManyErr()
|
func! ManyErr()
|
||||||
for i in range(10)
|
for i in range(10)
|
||||||
echoerr "FAIL ".i
|
echoerr "FAIL ".i
|
||||||
endfor
|
endfor
|
||||||
endfunc
|
endfunc
|
||||||
]])
|
]], false)
|
||||||
feed_data(':call ManyErr()\r')
|
feed_data(':call ManyErr()\r')
|
||||||
screen:expect{grid=[[
|
screen:expect{grid=[[
|
||||||
{8:Error detected while processing function ManyErr:} |
|
{8:Error detected while processing function ManyErr:} |
|
||||||
@@ -302,11 +302,11 @@ describe('TUI', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('accepts mouse wheel events #19992', function()
|
it('accepts mouse wheel events #19992', function()
|
||||||
child_session:request('nvim_command', [[
|
child_session:request('nvim_exec', [[
|
||||||
set number nostartofline nowrap mousescroll=hor:1,ver:1
|
set number nostartofline nowrap mousescroll=hor:1,ver:1
|
||||||
call setline(1, repeat([join(range(10), '----')], 10))
|
call setline(1, repeat([join(range(10), '----')], 10))
|
||||||
vsplit
|
vsplit
|
||||||
]])
|
]], false)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{11: 1 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
|
{11: 1 }{1:0}----1----2----3----4│{11: 1 }0----1----2----3----|
|
||||||
{11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----|
|
{11: 2 }0----1----2----3----4│{11: 2 }0----1----2----3----|
|
||||||
@@ -632,11 +632,11 @@ describe('TUI', function()
|
|||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]])
|
]])
|
||||||
child_session:request('nvim_command', [[
|
child_session:request('nvim_exec', [[
|
||||||
tab split
|
tab split
|
||||||
tabnew
|
tabnew
|
||||||
highlight Tabline ctermbg=NONE ctermfg=NONE cterm=underline
|
highlight Tabline ctermbg=NONE ctermfg=NONE cterm=underline
|
||||||
]])
|
]], false)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}|
|
{12: + [No Name] + [No Name] }{3: [No Name] }{1: }{12:X}|
|
||||||
{1: } |
|
{1: } |
|
||||||
@@ -669,7 +669,7 @@ describe('TUI', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('mouse events work with right-click menu', function()
|
it('mouse events work with right-click menu', function()
|
||||||
child_session:request('nvim_command', [[
|
child_session:request('nvim_exec', [[
|
||||||
call setline(1, 'popup menu test')
|
call setline(1, 'popup menu test')
|
||||||
set mouse=a mousemodel=popup
|
set mouse=a mousemodel=popup
|
||||||
|
|
||||||
@@ -679,7 +679,7 @@ describe('TUI', function()
|
|||||||
menu PopUp.baz :let g:menustr = 'baz'<CR>
|
menu PopUp.baz :let g:menustr = 'baz'<CR>
|
||||||
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
|
highlight Pmenu ctermbg=NONE ctermfg=NONE cterm=underline,reverse
|
||||||
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
|
highlight PmenuSel ctermbg=NONE ctermfg=NONE cterm=underline,reverse,bold
|
||||||
]])
|
]], false)
|
||||||
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{1:p}opup menu test |
|
{1:p}opup menu test |
|
||||||
@@ -1626,12 +1626,16 @@ end)
|
|||||||
|
|
||||||
describe('TUI FocusGained/FocusLost', function()
|
describe('TUI FocusGained/FocusLost', function()
|
||||||
local screen
|
local screen
|
||||||
|
local child_session
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
screen = thelpers.screen_setup(0, '["'..nvim_prog
|
local child_server = new_pipename()
|
||||||
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]')
|
screen = thelpers.screen_setup(0,
|
||||||
screen:expect{grid=[[
|
string.format(
|
||||||
|
[=[["%s", "--listen", "%s", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile noshowcmd noruler"]]=],
|
||||||
|
nvim_prog, child_server))
|
||||||
|
screen:expect([[
|
||||||
{1: } |
|
{1: } |
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
{4:~ }|
|
{4:~ }|
|
||||||
@@ -1639,22 +1643,16 @@ describe('TUI FocusGained/FocusLost', function()
|
|||||||
{5:[No Name] }|
|
{5:[No Name] }|
|
||||||
|
|
|
|
||||||
{3:-- TERMINAL --} |
|
{3:-- TERMINAL --} |
|
||||||
]]}
|
]])
|
||||||
feed_data(":autocmd FocusGained * echo 'gained'\n")
|
child_session = helpers.connect(child_server)
|
||||||
feed_data(":autocmd FocusLost * echo 'lost'\n")
|
child_session:request('nvim_exec', [[
|
||||||
|
autocmd FocusGained * echo 'gained'
|
||||||
|
autocmd FocusLost * echo 'lost'
|
||||||
|
]], false)
|
||||||
feed_data("\034\016") -- CTRL-\ CTRL-N
|
feed_data("\034\016") -- CTRL-\ CTRL-N
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('in normal-mode', function()
|
it('in normal-mode', function()
|
||||||
screen:expect{grid=[[
|
|
||||||
{1: } |
|
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{5:[No Name] }|
|
|
||||||
:autocmd FocusLost * echo 'lost' |
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]]}
|
|
||||||
retry(2, 3 * screen.timeout, function()
|
retry(2, 3 * screen.timeout, function()
|
||||||
feed_data('\027[I')
|
feed_data('\027[I')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@@ -1746,18 +1744,11 @@ describe('TUI FocusGained/FocusLost', function()
|
|||||||
-- Set up autocmds that modify the buffer, instead of just calling :echo.
|
-- Set up autocmds that modify the buffer, instead of just calling :echo.
|
||||||
-- This is how we can test handling of focus gained/lost during cmdline-mode.
|
-- This is how we can test handling of focus gained/lost during cmdline-mode.
|
||||||
-- See commit: 5cc87d4dabd02167117be7a978b5c8faaa975419.
|
-- See commit: 5cc87d4dabd02167117be7a978b5c8faaa975419.
|
||||||
feed_data(":autocmd!\n")
|
child_session:request('nvim_exec', [[
|
||||||
feed_data(":autocmd FocusLost * call append(line('$'), 'lost')\n")
|
autocmd!
|
||||||
feed_data(":autocmd FocusGained * call append(line('$'), 'gained')\n")
|
autocmd FocusLost * call append(line('$'), 'lost')
|
||||||
screen:expect{grid=[[
|
autocmd FocusGained * call append(line('$'), 'gained')
|
||||||
{1: } |
|
]], false)
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{4:~ }|
|
|
||||||
{5:[No Name] }|
|
|
||||||
|
|
|
||||||
{3:-- TERMINAL --} |
|
|
||||||
]]}
|
|
||||||
retry(2, 3 * screen.timeout, function()
|
retry(2, 3 * screen.timeout, function()
|
||||||
-- Enter cmdline-mode.
|
-- Enter cmdline-mode.
|
||||||
feed_data(':')
|
feed_data(':')
|
||||||
|
Reference in New Issue
Block a user