aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-03-03 07:44:16 +0800
committerGitHub <noreply@github.com>2023-03-03 07:44:16 +0800
commit361de6d54d41fc0fc8f8a89ec779696f3f7bb46e (patch)
tree86d15743ba85a3a6ba0a66641d66506946056a67 /src/nvim/testdir
parentfdb6b4d2e729211f0526ce75c6a3fcc636859bfd (diff)
downloadrneovim-361de6d54d41fc0fc8f8a89ec779696f3f7bb46e.tar.gz
rneovim-361de6d54d41fc0fc8f8a89ec779696f3f7bb46e.tar.bz2
rneovim-361de6d54d41fc0fc8f8a89ec779696f3f7bb46e.zip
vim-patch:9.0.1371: ballooneval interferes with Insert completion (#22487)
Problem: Ballooneval interferes with Insert completion. Solution: Ignore mouse-move events when completing. (closes vim/vim#12094, closes vim/vim#12092) https://github.com/vim/vim/commit/440d4cb55b84fd4b188630abc4a1312598649af0
Diffstat (limited to 'src/nvim/testdir')
-rw-r--r--src/nvim/testdir/test_ins_complete.vim48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_ins_complete.vim b/src/nvim/testdir/test_ins_complete.vim
index ec1379a378..af0856331d 100644
--- a/src/nvim/testdir/test_ins_complete.vim
+++ b/src/nvim/testdir/test_ins_complete.vim
@@ -375,6 +375,54 @@ func Test_completefunc_info()
set completefunc&
endfunc
+" Test that mouse scrolling/movement should not interrupt completion.
+func Test_mouse_scroll_move_during_completion()
+ new
+ com! -buffer TestCommand1 echo 'TestCommand1'
+ com! -buffer TestCommand2 echo 'TestCommand2'
+ call setline(1, ['', '', '', '', ''])
+ call cursor(5, 1)
+
+ " Without completion menu scrolling can move text.
+ set completeopt-=menu wrap
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelDown>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_notequal(1, winsaveview().topline)
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelUp>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_equal(1, winsaveview().topline)
+ set nowrap
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelRight>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_notequal(0, winsaveview().leftcol)
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelLeft>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_equal(0, winsaveview().leftcol)
+ call feedkeys("ccT\<C-X>\<C-V>\<MouseMove>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+
+ " With completion menu scrolling cannot move text.
+ set completeopt+=menu wrap
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelDown>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_equal(1, winsaveview().topline)
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelUp>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_equal(1, winsaveview().topline)
+ set nowrap
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelRight>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_equal(0, winsaveview().leftcol)
+ call feedkeys("ccT\<C-X>\<C-V>\<ScrollWheelLeft>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+ call assert_equal(0, winsaveview().leftcol)
+ call feedkeys("ccT\<C-X>\<C-V>\<MouseMove>\<C-V>", 'tx')
+ call assert_equal('TestCommand2', getline('.'))
+
+ bwipe!
+ set completeopt& wrap&
+endfunc
+
" Check that when using feedkeys() typeahead does not interrupt searching for
" completions.
func Test_compl_feedkeys()