mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
test: typing for helpers.meths
This commit is contained in:
@@ -12,8 +12,8 @@ describe('ui/mouse/input', function()
|
||||
|
||||
before_each(function()
|
||||
clear()
|
||||
meths.set_option_value('mouse', 'a', {})
|
||||
meths.set_option_value('list', true, {})
|
||||
meths.nvim_set_option_value('mouse', 'a', {})
|
||||
meths.nvim_set_option_value('list', true, {})
|
||||
-- NB: this is weird, but mostly irrelevant to the test
|
||||
-- So I didn't bother to change it
|
||||
command('set listchars=eol:$')
|
||||
@@ -69,7 +69,7 @@ describe('ui/mouse/input', function()
|
||||
end)
|
||||
|
||||
it("in external ui works with unset 'mouse'", function()
|
||||
meths.set_option_value('mouse', '', {})
|
||||
meths.nvim_set_option_value('mouse', '', {})
|
||||
feed('<LeftMouse><2,1>')
|
||||
screen:expect {
|
||||
grid = [[
|
||||
@@ -379,7 +379,7 @@ describe('ui/mouse/input', function()
|
||||
end)
|
||||
|
||||
it('left click in default tabline (position 24) closes tab', function()
|
||||
meths.set_option_value('hidden', true, {})
|
||||
meths.nvim_set_option_value('hidden', true, {})
|
||||
feed_command('%delete')
|
||||
insert('this is foo')
|
||||
feed_command('silent file foo | tabnew | file bar')
|
||||
@@ -399,7 +399,7 @@ describe('ui/mouse/input', function()
|
||||
end)
|
||||
|
||||
it('double click in default tabline (position 4) opens new tab', function()
|
||||
meths.set_option_value('hidden', true, {})
|
||||
meths.nvim_set_option_value('hidden', true, {})
|
||||
feed_command('%delete')
|
||||
insert('this is foo')
|
||||
feed_command('silent file foo | tabnew | file bar')
|
||||
@@ -432,8 +432,8 @@ describe('ui/mouse/input', function()
|
||||
return call('Test', a:000 + [2])
|
||||
endfunction
|
||||
]])
|
||||
meths.set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {})
|
||||
meths.set_option_value('showtabline', 2, {})
|
||||
meths.nvim_set_option_value('tabline', '%@Test@test%X-%5@Test2@test2', {})
|
||||
meths.nvim_set_option_value('showtabline', 2, {})
|
||||
screen:expect([[
|
||||
{fill:test-test2 }|
|
||||
testing |
|
||||
@@ -441,12 +441,12 @@ describe('ui/mouse/input', function()
|
||||
support and selectio^n |
|
||||
|
|
||||
]])
|
||||
meths.set_var('reply', {})
|
||||
meths.nvim_set_var('reply', {})
|
||||
end)
|
||||
|
||||
local check_reply = function(expected)
|
||||
eq(expected, meths.get_var('reply'))
|
||||
meths.set_var('reply', {})
|
||||
eq(expected, meths.nvim_get_var('reply'))
|
||||
meths.nvim_set_var('reply', {})
|
||||
end
|
||||
|
||||
local test_click = function(name, click_str, click_num, mouse_button, modifiers)
|
||||
@@ -475,7 +475,7 @@ describe('ui/mouse/input', function()
|
||||
for char in string.gmatch(modifiers, '%w') do
|
||||
modstr = modstr .. char .. '-' -- - not needed but should be accepted
|
||||
end
|
||||
meths.input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col)
|
||||
meths.nvim_input_mouse(buttons[mouse_button], 'press', modstr, 0, row, col)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
@@ -609,7 +609,7 @@ describe('ui/mouse/input', function()
|
||||
]],
|
||||
}
|
||||
|
||||
meths.input_mouse('left', 'press', '', 0, 6, 27)
|
||||
meths.nvim_input_mouse('left', 'press', '', 0, 6, 27)
|
||||
screen:expect {
|
||||
grid = [[
|
||||
testing │testing |
|
||||
@@ -624,7 +624,7 @@ describe('ui/mouse/input', function()
|
||||
|
|
||||
]],
|
||||
}
|
||||
meths.input_mouse('left', 'drag', '', 0, 7, 30)
|
||||
meths.nvim_input_mouse('left', 'drag', '', 0, 7, 30)
|
||||
|
||||
screen:expect {
|
||||
grid = [[
|
||||
@@ -779,7 +779,7 @@ describe('ui/mouse/input', function()
|
||||
end)
|
||||
|
||||
it('ctrl + left click will search for a tag', function()
|
||||
meths.set_option_value('tags', './non-existent-tags-file', {})
|
||||
meths.nvim_set_option_value('tags', './non-existent-tags-file', {})
|
||||
feed('<C-LeftMouse><0,0>')
|
||||
screen:expect([[
|
||||
{6:E433: No tags file} |
|
||||
@@ -792,28 +792,28 @@ describe('ui/mouse/input', function()
|
||||
end)
|
||||
|
||||
it('x1 and x2 can be triggered by api', function()
|
||||
meths.set_var('x1_pressed', 0)
|
||||
meths.set_var('x1_released', 0)
|
||||
meths.set_var('x2_pressed', 0)
|
||||
meths.set_var('x2_released', 0)
|
||||
meths.nvim_set_var('x1_pressed', 0)
|
||||
meths.nvim_set_var('x1_released', 0)
|
||||
meths.nvim_set_var('x2_pressed', 0)
|
||||
meths.nvim_set_var('x2_released', 0)
|
||||
command('nnoremap <X1Mouse> <Cmd>let g:x1_pressed += 1<CR>')
|
||||
command('nnoremap <X1Release> <Cmd>let g:x1_released += 1<CR>')
|
||||
command('nnoremap <X2Mouse> <Cmd>let g:x2_pressed += 1<CR>')
|
||||
command('nnoremap <X2Release> <Cmd>let g:x2_released += 1<CR>')
|
||||
meths.input_mouse('x1', 'press', '', 0, 0, 0)
|
||||
meths.input_mouse('x1', 'release', '', 0, 0, 0)
|
||||
meths.input_mouse('x2', 'press', '', 0, 0, 0)
|
||||
meths.input_mouse('x2', 'release', '', 0, 0, 0)
|
||||
eq(1, meths.get_var('x1_pressed'), 'x1 pressed once')
|
||||
eq(1, meths.get_var('x1_released'), 'x1 released once')
|
||||
eq(1, meths.get_var('x2_pressed'), 'x2 pressed once')
|
||||
eq(1, meths.get_var('x2_released'), 'x2 released once')
|
||||
meths.nvim_input_mouse('x1', 'press', '', 0, 0, 0)
|
||||
meths.nvim_input_mouse('x1', 'release', '', 0, 0, 0)
|
||||
meths.nvim_input_mouse('x2', 'press', '', 0, 0, 0)
|
||||
meths.nvim_input_mouse('x2', 'release', '', 0, 0, 0)
|
||||
eq(1, meths.nvim_get_var('x1_pressed'), 'x1 pressed once')
|
||||
eq(1, meths.nvim_get_var('x1_released'), 'x1 released once')
|
||||
eq(1, meths.nvim_get_var('x2_pressed'), 'x2 pressed once')
|
||||
eq(1, meths.nvim_get_var('x2_released'), 'x2 released once')
|
||||
end)
|
||||
|
||||
it('dragging vertical separator', function()
|
||||
screen:try_resize(45, 5)
|
||||
command('setlocal nowrap')
|
||||
local oldwin = meths.get_current_win().id
|
||||
local oldwin = meths.nvim_get_current_win().id
|
||||
command('rightbelow vnew')
|
||||
screen:expect([[
|
||||
testing │{0:^$} |
|
||||
@@ -822,9 +822,9 @@ describe('ui/mouse/input', function()
|
||||
{4:[No Name] [+] }{5:[No Name] }|
|
||||
|
|
||||
]])
|
||||
meths.input_mouse('left', 'press', '', 0, 0, 22)
|
||||
meths.nvim_input_mouse('left', 'press', '', 0, 0, 22)
|
||||
poke_eventloop()
|
||||
meths.input_mouse('left', 'drag', '', 0, 1, 12)
|
||||
meths.nvim_input_mouse('left', 'drag', '', 0, 1, 12)
|
||||
screen:expect([[
|
||||
testing │{0:^$} |
|
||||
mouse │{0:~ }|
|
||||
@@ -832,7 +832,7 @@ describe('ui/mouse/input', function()
|
||||
{4:< Name] [+] }{5:[No Name] }|
|
||||
|
|
||||
]])
|
||||
meths.input_mouse('left', 'drag', '', 0, 2, 2)
|
||||
meths.nvim_input_mouse('left', 'drag', '', 0, 2, 2)
|
||||
screen:expect([[
|
||||
te│{0:^$} |
|
||||
mo│{0:~ }|
|
||||
@@ -840,17 +840,17 @@ describe('ui/mouse/input', function()
|
||||
{4:< }{5:[No Name] }|
|
||||
|
|
||||
]])
|
||||
meths.input_mouse('left', 'release', '', 0, 2, 2)
|
||||
meths.set_option_value('statuscolumn', 'foobar', { win = oldwin })
|
||||
meths.nvim_input_mouse('left', 'release', '', 0, 2, 2)
|
||||
meths.nvim_set_option_value('statuscolumn', 'foobar', { win = oldwin })
|
||||
screen:expect([[
|
||||
{8:fo}│{0:^$} |
|
||||
{8:fo}│{0:~ }|*2
|
||||
{4:< }{5:[No Name] }|
|
||||
|
|
||||
]])
|
||||
meths.input_mouse('left', 'press', '', 0, 0, 2)
|
||||
meths.nvim_input_mouse('left', 'press', '', 0, 0, 2)
|
||||
poke_eventloop()
|
||||
meths.input_mouse('left', 'drag', '', 0, 1, 12)
|
||||
meths.nvim_input_mouse('left', 'drag', '', 0, 1, 12)
|
||||
screen:expect([[
|
||||
{8:foobar}testin│{0:^$} |
|
||||
{8:foobar}mouse │{0:~ }|
|
||||
@@ -858,7 +858,7 @@ describe('ui/mouse/input', function()
|
||||
{4:< Name] [+] }{5:[No Name] }|
|
||||
|
|
||||
]])
|
||||
meths.input_mouse('left', 'drag', '', 0, 2, 22)
|
||||
meths.nvim_input_mouse('left', 'drag', '', 0, 2, 22)
|
||||
screen:expect([[
|
||||
{8:foobar}testing │{0:^$} |
|
||||
{8:foobar}mouse │{0:~ }|
|
||||
@@ -866,7 +866,7 @@ describe('ui/mouse/input', function()
|
||||
{4:[No Name] [+] }{5:[No Name] }|
|
||||
|
|
||||
]])
|
||||
meths.input_mouse('left', 'release', '', 0, 2, 22)
|
||||
meths.nvim_input_mouse('left', 'release', '', 0, 2, 22)
|
||||
end)
|
||||
|
||||
local function wheel(use_api)
|
||||
@@ -901,7 +901,7 @@ describe('ui/mouse/input', function()
|
||||
:vsp |
|
||||
]])
|
||||
if use_api then
|
||||
meths.input_mouse('wheel', 'down', '', 0, 0, 0)
|
||||
meths.nvim_input_mouse('wheel', 'down', '', 0, 0, 0)
|
||||
else
|
||||
feed('<ScrollWheelDown><0,0>')
|
||||
end
|
||||
@@ -922,7 +922,7 @@ describe('ui/mouse/input', function()
|
||||
:vsp |
|
||||
]])
|
||||
if use_api then
|
||||
meths.input_mouse('wheel', 'up', '', 0, 0, 27)
|
||||
meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 27)
|
||||
else
|
||||
feed('<ScrollWheelUp><27,0>')
|
||||
end
|
||||
@@ -943,8 +943,8 @@ describe('ui/mouse/input', function()
|
||||
:vsp |
|
||||
]])
|
||||
if use_api then
|
||||
meths.input_mouse('wheel', 'up', '', 0, 7, 27)
|
||||
meths.input_mouse('wheel', 'up', '', 0, 7, 27)
|
||||
meths.nvim_input_mouse('wheel', 'up', '', 0, 7, 27)
|
||||
meths.nvim_input_mouse('wheel', 'up', '', 0, 7, 27)
|
||||
else
|
||||
feed('<ScrollWheelUp><27,7><ScrollWheelUp>')
|
||||
end
|
||||
@@ -1016,7 +1016,7 @@ describe('ui/mouse/input', function()
|
||||
|
|
||||
]])
|
||||
|
||||
meths.input_mouse('wheel', 'left', '', 0, 0, 27)
|
||||
meths.nvim_input_mouse('wheel', 'left', '', 0, 0, 27)
|
||||
screen:expect([[
|
||||
|*2
|
||||
n bbbbbbbbbbbbbbbbbbb^b |
|
||||
@@ -1025,7 +1025,7 @@ describe('ui/mouse/input', function()
|
||||
]])
|
||||
|
||||
feed('^')
|
||||
meths.input_mouse('wheel', 'right', '', 0, 0, 0)
|
||||
meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 0)
|
||||
screen:expect([[
|
||||
g |
|
||||
|
|
||||
@@ -1048,7 +1048,7 @@ describe('ui/mouse/input', function()
|
||||
|
|
||||
]])
|
||||
|
||||
meths.input_mouse('wheel', 'right', '', 0, 0, 27)
|
||||
meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 27)
|
||||
screen:expect([[
|
||||
g |
|
||||
|
|
||||
@@ -1068,7 +1068,7 @@ describe('ui/mouse/input', function()
|
||||
|
|
||||
]])
|
||||
|
||||
meths.input_mouse('wheel', 'right', '', 0, 0, 27)
|
||||
meths.nvim_input_mouse('wheel', 'right', '', 0, 0, 27)
|
||||
screen:expect([[
|
||||
g |
|
||||
|
|
||||
@@ -1614,30 +1614,30 @@ describe('ui/mouse/input', function()
|
||||
|
||||
describe('(extmarks)', function()
|
||||
before_each(function()
|
||||
local ns = meths.create_namespace('conceal')
|
||||
meths.buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' })
|
||||
meths.buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' })
|
||||
meths.buf_set_extmark(0, ns, 2, 0, { end_col = 1, conceal = '>' })
|
||||
local ns = meths.nvim_create_namespace('conceal')
|
||||
meths.nvim_buf_set_extmark(0, ns, 0, 11, { end_col = 12, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 0, 14, { end_col = 15, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 1, 5, { end_col = 6, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 1, 8, { end_col = 9, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 1, 10, { end_col = 11, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 1, 13, { end_col = 14, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 1, 15, { end_col = 16, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 1, 18, { end_col = 19, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 2, 24, { end_col = 25, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 2, 29, { end_col = 30, conceal = '' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 2, 25, { end_col = 29, conceal = 'X' })
|
||||
meths.nvim_buf_set_extmark(0, ns, 2, 0, { end_col = 1, conceal = '>' })
|
||||
end)
|
||||
test_mouse_click_conceal()
|
||||
end)
|
||||
end)
|
||||
|
||||
it('getmousepos() works correctly', function()
|
||||
local winwidth = meths.get_option_value('winwidth', {})
|
||||
local winwidth = meths.nvim_get_option_value('winwidth', {})
|
||||
-- Set winwidth=1 so that window sizes don't change.
|
||||
meths.set_option_value('winwidth', 1, {})
|
||||
meths.nvim_set_option_value('winwidth', 1, {})
|
||||
command('tabedit')
|
||||
local tabpage = meths.get_current_tabpage()
|
||||
local tabpage = meths.nvim_get_current_tabpage()
|
||||
insert('hello')
|
||||
command('vsplit')
|
||||
local opts = {
|
||||
@@ -1651,18 +1651,18 @@ describe('ui/mouse/input', function()
|
||||
border = 'single',
|
||||
focusable = 1,
|
||||
}
|
||||
local float = meths.open_win(meths.get_current_buf(), false, opts)
|
||||
local float = meths.nvim_open_win(meths.nvim_get_current_buf(), false, opts)
|
||||
command('redraw')
|
||||
local lines = meths.get_option_value('lines', {})
|
||||
local columns = meths.get_option_value('columns', {})
|
||||
local lines = meths.nvim_get_option_value('lines', {})
|
||||
local columns = meths.nvim_get_option_value('columns', {})
|
||||
|
||||
-- Test that screenrow and screencol are set properly for all positions.
|
||||
for row = 0, lines - 1 do
|
||||
for col = 0, columns - 1 do
|
||||
-- Skip the X button that would close the tab.
|
||||
if row ~= 0 or col ~= columns - 1 then
|
||||
meths.input_mouse('left', 'press', '', 0, row, col)
|
||||
meths.set_current_tabpage(tabpage)
|
||||
meths.nvim_input_mouse('left', 'press', '', 0, row, col)
|
||||
meths.nvim_set_current_tabpage(tabpage)
|
||||
local mousepos = funcs.getmousepos()
|
||||
eq(row + 1, mousepos.screenrow)
|
||||
eq(col + 1, mousepos.screencol)
|
||||
@@ -1686,7 +1686,7 @@ describe('ui/mouse/input', function()
|
||||
for win_col = 0, opts.width + 1 do
|
||||
local row = win_row + opts.row
|
||||
local col = win_col + opts.col
|
||||
meths.input_mouse('left', 'press', '', 0, row, col)
|
||||
meths.nvim_input_mouse('left', 'press', '', 0, row, col)
|
||||
local mousepos = funcs.getmousepos()
|
||||
eq(float.id, mousepos.winid)
|
||||
eq(win_row + 1, mousepos.winrow)
|
||||
@@ -1715,13 +1715,13 @@ describe('ui/mouse/input', function()
|
||||
-- Test that mouse position values are properly set for the floating
|
||||
-- window, after removing the border.
|
||||
opts.border = 'none'
|
||||
meths.win_set_config(float, opts)
|
||||
meths.nvim_win_set_config(float, opts)
|
||||
command('redraw')
|
||||
for win_row = 0, opts.height - 1 do
|
||||
for win_col = 0, opts.width - 1 do
|
||||
local row = win_row + opts.row
|
||||
local col = win_col + opts.col
|
||||
meths.input_mouse('left', 'press', '', 0, row, col)
|
||||
meths.nvim_input_mouse('left', 'press', '', 0, row, col)
|
||||
local mousepos = funcs.getmousepos()
|
||||
eq(float.id, mousepos.winid)
|
||||
eq(win_row + 1, mousepos.winrow)
|
||||
@@ -1740,14 +1740,14 @@ describe('ui/mouse/input', function()
|
||||
-- that getmousepos() does not consider unfocusable floats. (see discussion
|
||||
-- in PR #14937 for details).
|
||||
opts.focusable = false
|
||||
meths.win_set_config(float, opts)
|
||||
meths.nvim_win_set_config(float, opts)
|
||||
command('redraw')
|
||||
for nr = 1, 2 do
|
||||
for win_row = 0, funcs.winheight(nr) - 1 do
|
||||
for win_col = 0, funcs.winwidth(nr) - 1 do
|
||||
local row = win_row + funcs.win_screenpos(nr)[1] - 1
|
||||
local col = win_col + funcs.win_screenpos(nr)[2] - 1
|
||||
meths.input_mouse('left', 'press', '', 0, row, col)
|
||||
meths.nvim_input_mouse('left', 'press', '', 0, row, col)
|
||||
local mousepos = funcs.getmousepos()
|
||||
eq(funcs.win_getid(nr), mousepos.winid)
|
||||
eq(win_row + 1, mousepos.winrow)
|
||||
@@ -1764,34 +1764,34 @@ describe('ui/mouse/input', function()
|
||||
|
||||
-- Restore state and release mouse.
|
||||
command('tabclose!')
|
||||
meths.set_option_value('winwidth', winwidth, {})
|
||||
meths.input_mouse('left', 'release', '', 0, 0, 0)
|
||||
meths.nvim_set_option_value('winwidth', winwidth, {})
|
||||
meths.nvim_input_mouse('left', 'release', '', 0, 0, 0)
|
||||
end)
|
||||
|
||||
it('scroll keys are not translated into multiclicks and can be mapped #6211 #6989', function()
|
||||
meths.set_var('mouse_up', 0)
|
||||
meths.set_var('mouse_up2', 0)
|
||||
meths.nvim_set_var('mouse_up', 0)
|
||||
meths.nvim_set_var('mouse_up2', 0)
|
||||
command('nnoremap <ScrollWheelUp> <Cmd>let g:mouse_up += 1<CR>')
|
||||
command('nnoremap <2-ScrollWheelUp> <Cmd>let g:mouse_up2 += 1<CR>')
|
||||
feed('<ScrollWheelUp><0,0>')
|
||||
feed('<ScrollWheelUp><0,0>')
|
||||
meths.input_mouse('wheel', 'up', '', 0, 0, 0)
|
||||
meths.input_mouse('wheel', 'up', '', 0, 0, 0)
|
||||
eq(4, meths.get_var('mouse_up'))
|
||||
eq(0, meths.get_var('mouse_up2'))
|
||||
meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 0)
|
||||
meths.nvim_input_mouse('wheel', 'up', '', 0, 0, 0)
|
||||
eq(4, meths.nvim_get_var('mouse_up'))
|
||||
eq(0, meths.nvim_get_var('mouse_up2'))
|
||||
end)
|
||||
|
||||
it('<MouseMove> is not translated into multiclicks and can be mapped', function()
|
||||
meths.set_var('mouse_move', 0)
|
||||
meths.set_var('mouse_move2', 0)
|
||||
meths.nvim_set_var('mouse_move', 0)
|
||||
meths.nvim_set_var('mouse_move2', 0)
|
||||
command('nnoremap <MouseMove> <Cmd>let g:mouse_move += 1<CR>')
|
||||
command('nnoremap <2-MouseMove> <Cmd>let g:mouse_move2 += 1<CR>')
|
||||
feed('<MouseMove><0,0>')
|
||||
feed('<MouseMove><0,0>')
|
||||
meths.input_mouse('move', '', '', 0, 0, 0)
|
||||
meths.input_mouse('move', '', '', 0, 0, 0)
|
||||
eq(4, meths.get_var('mouse_move'))
|
||||
eq(0, meths.get_var('mouse_move2'))
|
||||
meths.nvim_input_mouse('move', '', '', 0, 0, 0)
|
||||
meths.nvim_input_mouse('move', '', '', 0, 0, 0)
|
||||
eq(4, meths.nvim_get_var('mouse_move'))
|
||||
eq(0, meths.nvim_get_var('mouse_move2'))
|
||||
end)
|
||||
|
||||
it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function()
|
||||
@@ -1818,102 +1818,102 @@ describe('ui/mouse/input', function()
|
||||
vmenu PopUp.baz y:<C-U>let g:menustr = 'baz'<CR>
|
||||
]])
|
||||
|
||||
meths.win_set_cursor(0, { 1, 0 })
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 4)
|
||||
meths.input_mouse('right', 'release', '', 0, 0, 4)
|
||||
meths.nvim_win_set_cursor(0, { 1, 0 })
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 0, 4)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 0, 4)
|
||||
feed('<Down><Down><CR>')
|
||||
eq('bar', meths.get_var('menustr'))
|
||||
eq({ 1, 4 }, meths.win_get_cursor(0))
|
||||
eq('bar', meths.nvim_get_var('menustr'))
|
||||
eq({ 1, 4 }, meths.nvim_win_get_cursor(0))
|
||||
|
||||
-- Test for right click in visual mode inside the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 9 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 9 })
|
||||
feed('vee')
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 11)
|
||||
meths.input_mouse('right', 'release', '', 0, 0, 11)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 0, 11)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 0, 11)
|
||||
feed('<Down><CR>')
|
||||
eq({ 1, 9 }, meths.win_get_cursor(0))
|
||||
eq({ 1, 9 }, meths.nvim_win_get_cursor(0))
|
||||
eq('ran away', funcs.getreg('"'))
|
||||
|
||||
-- Test for right click in visual mode right before the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 9 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 9 })
|
||||
feed('vee')
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 8)
|
||||
meths.input_mouse('right', 'release', '', 0, 0, 8)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 0, 8)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 0, 8)
|
||||
feed('<Down><CR>')
|
||||
eq({ 1, 8 }, meths.win_get_cursor(0))
|
||||
eq({ 1, 8 }, meths.nvim_win_get_cursor(0))
|
||||
eq('', funcs.getreg('"'))
|
||||
|
||||
-- Test for right click in visual mode right after the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 9 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 9 })
|
||||
feed('vee')
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 17)
|
||||
meths.input_mouse('right', 'release', '', 0, 0, 17)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 0, 17)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 0, 17)
|
||||
feed('<Down><CR>')
|
||||
eq({ 1, 17 }, meths.win_get_cursor(0))
|
||||
eq({ 1, 17 }, meths.nvim_win_get_cursor(0))
|
||||
eq('', funcs.getreg('"'))
|
||||
|
||||
-- Test for right click in block-wise visual mode inside the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 15 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 15 })
|
||||
feed('<C-V>j3l')
|
||||
meths.input_mouse('right', 'press', '', 0, 1, 16)
|
||||
meths.input_mouse('right', 'release', '', 0, 1, 16)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 1, 16)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 1, 16)
|
||||
feed('<Down><CR>')
|
||||
eq({ 1, 15 }, meths.win_get_cursor(0))
|
||||
eq({ 1, 15 }, meths.nvim_win_get_cursor(0))
|
||||
eq('\0224', funcs.getregtype('"'))
|
||||
|
||||
-- Test for right click in block-wise visual mode outside the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 15 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 15 })
|
||||
feed('<C-V>j3l')
|
||||
meths.input_mouse('right', 'press', '', 0, 1, 1)
|
||||
meths.input_mouse('right', 'release', '', 0, 1, 1)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 1, 1)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 1, 1)
|
||||
feed('<Down><CR>')
|
||||
eq({ 2, 1 }, meths.win_get_cursor(0))
|
||||
eq({ 2, 1 }, meths.nvim_win_get_cursor(0))
|
||||
eq('v', funcs.getregtype('"'))
|
||||
eq('', funcs.getreg('"'))
|
||||
|
||||
-- Test for right click in line-wise visual mode inside the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 15 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 15 })
|
||||
feed('V')
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 9)
|
||||
meths.input_mouse('right', 'release', '', 0, 0, 9)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 0, 9)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 0, 9)
|
||||
feed('<Down><CR>')
|
||||
eq({ 1, 0 }, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
|
||||
eq({ 1, 0 }, meths.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
|
||||
eq('V', funcs.getregtype('"'))
|
||||
eq(1, #funcs.getreg('"', 1, true))
|
||||
|
||||
-- Test for right click in multi-line line-wise visual mode inside the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 15 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 15 })
|
||||
feed('Vj')
|
||||
meths.input_mouse('right', 'press', '', 0, 1, 19)
|
||||
meths.input_mouse('right', 'release', '', 0, 1, 19)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 1, 19)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 1, 19)
|
||||
feed('<Down><CR>')
|
||||
eq({ 1, 0 }, meths.win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
|
||||
eq({ 1, 0 }, meths.nvim_win_get_cursor(0)) -- After yanking, the cursor goes to 1,1
|
||||
eq('V', funcs.getregtype('"'))
|
||||
eq(2, #funcs.getreg('"', 1, true))
|
||||
|
||||
-- Test for right click in line-wise visual mode outside the selection
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 15 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 15 })
|
||||
feed('V')
|
||||
meths.input_mouse('right', 'press', '', 0, 1, 9)
|
||||
meths.input_mouse('right', 'release', '', 0, 1, 9)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 1, 9)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 1, 9)
|
||||
feed('<Down><CR>')
|
||||
eq({ 2, 9 }, meths.win_get_cursor(0))
|
||||
eq({ 2, 9 }, meths.nvim_win_get_cursor(0))
|
||||
eq('', funcs.getreg('"'))
|
||||
|
||||
-- Try clicking outside the window
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 2, 1 })
|
||||
meths.nvim_win_set_cursor(0, { 2, 1 })
|
||||
feed('vee')
|
||||
meths.input_mouse('right', 'press', '', 0, 6, 1)
|
||||
meths.input_mouse('right', 'release', '', 0, 6, 1)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 6, 1)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 6, 1)
|
||||
feed('<Down><CR>')
|
||||
eq(2, funcs.winnr())
|
||||
eq('', funcs.getreg('"'))
|
||||
@@ -1922,12 +1922,12 @@ describe('ui/mouse/input', function()
|
||||
command('wincmd t')
|
||||
command('rightbelow vsplit')
|
||||
funcs.setreg('"', '')
|
||||
meths.win_set_cursor(0, { 1, 9 })
|
||||
meths.nvim_win_set_cursor(0, { 1, 9 })
|
||||
feed('vee')
|
||||
meths.input_mouse('right', 'press', '', 0, 0, 52)
|
||||
meths.input_mouse('right', 'release', '', 0, 0, 52)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 0, 52)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 0, 52)
|
||||
feed('<Down><CR>')
|
||||
eq({ 1, 9 }, meths.win_get_cursor(0))
|
||||
eq({ 1, 9 }, meths.nvim_win_get_cursor(0))
|
||||
eq('ran away', funcs.getreg('"'))
|
||||
|
||||
-- Test for right click inside visual selection at bottom of window with winbar
|
||||
@@ -1935,10 +1935,10 @@ describe('ui/mouse/input', function()
|
||||
feed('2yyP')
|
||||
funcs.setreg('"', '')
|
||||
feed('G$vbb')
|
||||
meths.input_mouse('right', 'press', '', 0, 4, 61)
|
||||
meths.input_mouse('right', 'release', '', 0, 4, 61)
|
||||
meths.nvim_input_mouse('right', 'press', '', 0, 4, 61)
|
||||
meths.nvim_input_mouse('right', 'release', '', 0, 4, 61)
|
||||
feed('<Down><CR>')
|
||||
eq({ 4, 20 }, meths.win_get_cursor(0))
|
||||
eq({ 4, 20 }, meths.nvim_win_get_cursor(0))
|
||||
eq('the moon', funcs.getreg('"'))
|
||||
end)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user