aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-25 06:41:01 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-25 07:23:24 +0800
commit48a35106efefa8f74d850d3eac365dc76b008ca3 (patch)
tree0a2a522f4a01562d571809ed58f42a0d203f505c
parentc8fe8c5ea4b57b4fb0aaf022b94aa7377c5b7a60 (diff)
downloadrneovim-48a35106efefa8f74d850d3eac365dc76b008ca3.tar.gz
rneovim-48a35106efefa8f74d850d3eac365dc76b008ca3.tar.bz2
rneovim-48a35106efefa8f74d850d3eac365dc76b008ca3.zip
vim-patch:8.2.4818: no test for what 8.2.4806 fixes
Problem: No test for what 8.2.4806 fixes. Solution: Add a test. (closes vim/vim#10727) https://github.com/vim/vim/commit/ac92ab771952b2a9ee39ea6fa5e70e4c072942d5 Test cannot be used because it must use test_setmouse(). Use a Lua test.
-rw-r--r--src/nvim/testdir/test_mapping.vim29
-rw-r--r--test/functional/legacy/mapping_spec.lua15
2 files changed, 43 insertions, 1 deletions
diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim
index a8dd0ca286..a9500f8f77 100644
--- a/src/nvim/testdir/test_mapping.vim
+++ b/src/nvim/testdir/test_mapping.vim
@@ -676,6 +676,35 @@ func Test_plug_remap()
%bw!
endfunc
+func Test_mouse_drag_mapped_start_select()
+ CheckFunction test_setmouse
+ set mouse=a
+ set selectmode=key,mouse
+ func ClickExpr()
+ call test_setmouse(1, 1)
+ return "\<LeftMouse>"
+ endfunc
+ func DragExpr()
+ call test_setmouse(1, 2)
+ return "\<LeftDrag>"
+ endfunc
+ nnoremap <expr> <F2> ClickExpr()
+ nmap <expr> <F3> DragExpr()
+
+ nnoremap <LeftDrag> <LeftDrag><Cmd><CR>
+ exe "normal \<F2>\<F3>"
+ call assert_equal('s', mode())
+ exe "normal! \<C-\>\<C-N>"
+
+ nunmap <LeftDrag>
+ nunmap <F2>
+ nunmap <F3>
+ delfunc ClickExpr
+ delfunc DragExpr
+ set selectmode&
+ set mouse&
+endfunc
+
" Test for mapping <LeftDrag> in Insert mode
func Test_mouse_drag_insert_map()
CheckFunction test_setmouse
diff --git a/test/functional/legacy/mapping_spec.lua b/test/functional/legacy/mapping_spec.lua
index aa29698589..0f65d5eb65 100644
--- a/test/functional/legacy/mapping_spec.lua
+++ b/test/functional/legacy/mapping_spec.lua
@@ -129,10 +129,23 @@ describe('mapping', function()
]])
end)
+ it('dragging starts Select mode even if coming from mapping vim-patch:8.2.4806', function()
+ command('set mouse=a')
+ command('set selectmode=mouse')
+
+ command('nnoremap <LeftDrag> <LeftDrag><Cmd><CR>')
+ sleep(10)
+ meths.input_mouse('left', 'press', '', 0, 0, 0)
+ sleep(10)
+ meths.input_mouse('left', 'drag', '', 0, 0, 1)
+ sleep(10)
+ eq('s', eval('mode()'))
+ end)
+
it('<LeftDrag> mapping in Insert mode works correctly vim-patch:8.2.4692', function()
command('set mouse=a')
- command([[inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>]])
+ command('inoremap <LeftDrag> <LeftDrag><Cmd>let g:dragged = 1<CR>')
feed('i')
sleep(10)
meths.input_mouse('left', 'press', '', 0, 0, 0)