aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ui/mouse_spec.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
commit9243becbedbb6a1592208051f8fa2b090dcc5e7d (patch)
tree607c2a862ec3f4399b8766383f6f8e04c4aa43b4 /test/functional/ui/mouse_spec.lua
parent9e40b6e9e1bc67f2d856adb837ee64dd0e25b717 (diff)
parent3c48d3c83fc21dbc0841f9210f04bdb073d73cd1 (diff)
downloadrneovim-usermarks.tar.gz
rneovim-usermarks.tar.bz2
rneovim-usermarks.zip
Merge remote-tracking branch 'upstream/master' into usermarksusermarks
Diffstat (limited to 'test/functional/ui/mouse_spec.lua')
-rw-r--r--test/functional/ui/mouse_spec.lua284
1 files changed, 277 insertions, 7 deletions
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index 9896b11218..f705678bd5 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -4,6 +4,7 @@ local clear, feed, meths = helpers.clear, helpers.feed, helpers.meths
local insert, feed_command = helpers.insert, helpers.feed_command
local eq, funcs = helpers.eq, helpers.funcs
local command = helpers.command
+local exec = helpers.exec
describe('ui/mouse/input', function()
local screen
@@ -648,8 +649,10 @@ describe('ui/mouse/input', function()
]]}
end)
- it('two clicks will select the word and enter VISUAL', function()
- feed('<LeftMouse><2,2><LeftMouse><2,2>')
+ it('two clicks will enter VISUAL and dragging selects words', function()
+ feed('<LeftMouse><2,2>')
+ feed('<LeftRelease><2,2>')
+ feed('<LeftMouse><2,2>')
screen:expect([[
testing |
mouse |
@@ -657,10 +660,38 @@ describe('ui/mouse/input', function()
{0:~ }|
{2:-- VISUAL --} |
]])
+ feed('<LeftDrag><0,1>')
+ screen:expect([[
+ testing |
+ ^m{1:ouse} |
+ {1:support} and selection |
+ {0:~ }|
+ {2:-- VISUAL --} |
+ ]])
+ feed('<LeftDrag><4,0>')
+ screen:expect([[
+ ^t{1:esting} |
+ {1:mouse} |
+ {1:support} and selection |
+ {0:~ }|
+ {2:-- VISUAL --} |
+ ]])
+ feed('<LeftDrag><14,2>')
+ screen:expect([[
+ testing |
+ mouse |
+ {1:support and selectio}^n |
+ {0:~ }|
+ {2:-- VISUAL --} |
+ ]])
end)
- it('three clicks will select the line and enter VISUAL LINE', function()
- feed('<LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2>')
+ it('three clicks will enter VISUAL LINE and dragging selects lines', function()
+ feed('<LeftMouse><2,2>')
+ feed('<LeftRelease><2,2>')
+ feed('<LeftMouse><2,2>')
+ feed('<LeftRelease><2,2>')
+ feed('<LeftMouse><2,2>')
screen:expect([[
testing |
mouse |
@@ -668,10 +699,40 @@ describe('ui/mouse/input', function()
{0:~ }|
{2:-- VISUAL LINE --} |
]])
+ feed('<LeftDrag><0,1>')
+ screen:expect([[
+ testing |
+ ^m{1:ouse} |
+ {1:support and selection} |
+ {0:~ }|
+ {2:-- VISUAL LINE --} |
+ ]])
+ feed('<LeftDrag><4,0>')
+ screen:expect([[
+ {1:test}^i{1:ng} |
+ {1:mouse} |
+ {1:support and selection} |
+ {0:~ }|
+ {2:-- VISUAL LINE --} |
+ ]])
+ feed('<LeftDrag><14,2>')
+ screen:expect([[
+ testing |
+ mouse |
+ {1:support and se}^l{1:ection} |
+ {0:~ }|
+ {2:-- VISUAL LINE --} |
+ ]])
end)
- it('four clicks will enter VISUAL BLOCK', function()
- feed('<LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2><LeftMouse><2,2>')
+ it('four clicks will enter VISUAL BLOCK and dragging selects blockwise', function()
+ feed('<LeftMouse><2,2>')
+ feed('<LeftRelease><2,2>')
+ feed('<LeftMouse><2,2>')
+ feed('<LeftRelease><2,2>')
+ feed('<LeftMouse><2,2>')
+ feed('<LeftRelease><2,2>')
+ feed('<LeftMouse><2,2>')
screen:expect([[
testing |
mouse |
@@ -679,6 +740,30 @@ describe('ui/mouse/input', function()
{0:~ }|
{2:-- VISUAL BLOCK --} |
]])
+ feed('<LeftDrag><0,1>')
+ screen:expect([[
+ testing |
+ ^m{1:ou}se |
+ {1:sup}port and selection |
+ {0:~ }|
+ {2:-- VISUAL BLOCK --} |
+ ]])
+ feed('<LeftDrag><4,0>')
+ screen:expect([[
+ te{1:st}^ing |
+ mo{1:use} |
+ su{1:ppo}rt and selection |
+ {0:~ }|
+ {2:-- VISUAL BLOCK --} |
+ ]])
+ feed('<LeftDrag><14,2>')
+ screen:expect([[
+ testing |
+ mouse |
+ su{1:pport and se}^lection |
+ {0:~ }|
+ {2:-- VISUAL BLOCK --} |
+ ]])
end)
it('right click extends visual selection to the clicked location', function()
@@ -883,6 +968,49 @@ describe('ui/mouse/input', function()
]])
end)
+ it("'sidescrolloff' applies to horizontal scrolling", function()
+ command('set nowrap')
+ command('set sidescrolloff=4')
+
+ feed("I <esc>020ib<esc>0")
+ screen:expect([[
+ testing |
+ mouse |
+ ^bbbbbbbbbbbbbbbbbbbb supp|
+ {0:~ }|
+ |
+ ]])
+
+ meths.input_mouse('wheel', 'right', '', 0, 0, 27)
+ screen:expect([[
+ g |
+ |
+ bbbb^bbbbbbbbbb support an|
+ {0:~ }|
+ |
+ ]])
+
+ -- window-local 'sidescrolloff' should override global value. #21162
+ command('setlocal sidescrolloff=2')
+ feed('0')
+ screen:expect([[
+ testing |
+ mouse |
+ ^bbbbbbbbbbbbbbbbbbbb supp|
+ {0:~ }|
+ |
+ ]])
+
+ meths.input_mouse('wheel', 'right', '', 0, 0, 27)
+ screen:expect([[
+ g |
+ |
+ bb^bbbbbbbbbbbb support an|
+ {0:~ }|
+ |
+ ]])
+ end)
+
describe('on concealed text', function()
-- Helpful for reading the test expectations:
-- :match Error /\^/
@@ -1585,9 +1713,151 @@ describe('ui/mouse/input', function()
eq(0, meths.get_var('mouse_up2'))
end)
- it('feeding <MouseMove> does not use uninitialized memory #19480', function()
+ it('<MouseMove> is not translated into multiclicks and can be mapped', function()
+ meths.set_var('mouse_move', 0)
+ meths.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'))
+ end)
+
+ it('feeding <MouseMove> in Normal mode does not use uninitialized memory #19480', function()
feed('<MouseMove>')
helpers.poke_eventloop()
helpers.assert_alive()
end)
+
+ it('mousemodel=popup_setpos', function()
+ screen:try_resize(80, 24)
+ exec([[
+ 5new
+ call setline(1, ['the dish ran away with the spoon',
+ \ 'the cow jumped over the moon' ])
+
+ set mouse=a mousemodel=popup_setpos
+
+ aunmenu PopUp
+ nmenu PopUp.foo :let g:menustr = 'foo'<CR>
+ nmenu PopUp.bar :let g:menustr = 'bar'<CR>
+ nmenu PopUp.baz :let g:menustr = 'baz'<CR>
+ vmenu PopUp.foo y:<C-U>let g:menustr = 'foo'<CR>
+ vmenu PopUp.bar y:<C-U>let g:menustr = 'bar'<CR>
+ 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)
+ feed('<Down><Down><CR>')
+ eq('bar', meths.get_var('menustr'))
+ eq({1, 4}, meths.win_get_cursor(0))
+
+ -- Test for right click in visual mode inside the selection
+ funcs.setreg('"', '')
+ meths.win_set_cursor(0, {1, 9})
+ feed('vee')
+ meths.input_mouse('right', 'press', '', 0, 0, 11)
+ meths.input_mouse('right', 'release', '', 0, 0, 11)
+ feed('<Down><CR>')
+ eq({1, 9}, meths.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})
+ feed('vee')
+ meths.input_mouse('right', 'press', '', 0, 0, 8)
+ meths.input_mouse('right', 'release', '', 0, 0, 8)
+ feed('<Down><CR>')
+ eq({1, 8}, meths.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})
+ feed('vee')
+ meths.input_mouse('right', 'press', '', 0, 0, 17)
+ meths.input_mouse('right', 'release', '', 0, 0, 17)
+ feed('<Down><CR>')
+ eq({1, 17}, meths.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})
+ feed('<C-V>j3l')
+ meths.input_mouse('right', 'press', '', 0, 1, 16)
+ meths.input_mouse('right', 'release', '', 0, 1, 16)
+ feed('<Down><CR>')
+ eq({1, 15}, meths.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})
+ feed('<C-V>j3l')
+ meths.input_mouse('right', 'press', '', 0, 1, 1)
+ meths.input_mouse('right', 'release', '', 0, 1, 1)
+ feed('<Down><CR>')
+ eq({2, 1}, meths.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})
+ feed('V')
+ meths.input_mouse('right', 'press', '', 0, 0, 9)
+ meths.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('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})
+ feed('Vj')
+ meths.input_mouse('right', 'press', '', 0, 1, 19)
+ meths.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('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})
+ feed('V')
+ meths.input_mouse('right', 'press', '', 0, 1, 9)
+ meths.input_mouse('right', 'release', '', 0, 1, 9)
+ feed('<Down><CR>')
+ eq({2, 9}, meths.win_get_cursor(0))
+ eq('', funcs.getreg('"'))
+
+ -- Try clicking on the status line
+ funcs.setreg('"', '')
+ meths.win_set_cursor(0, {1, 9})
+ feed('vee')
+ meths.input_mouse('right', 'press', '', 0, 5, 1)
+ meths.input_mouse('right', 'release', '', 0, 5, 1)
+ feed('<Down><CR>')
+ eq({1, 9}, meths.win_get_cursor(0))
+ eq('ran away', funcs.getreg('"'))
+
+ -- Try clicking outside the window
+ funcs.setreg('"', '')
+ meths.win_set_cursor(0, {2, 1})
+ feed('vee')
+ meths.input_mouse('right', 'press', '', 0, 6, 1)
+ meths.input_mouse('right', 'release', '', 0, 6, 1)
+ feed('<Down><CR>')
+ eq(2, funcs.winnr())
+ eq('', funcs.getreg('"'))
+ end)
end)