diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-03-03 07:44:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 07:44:16 +0800 |
commit | 361de6d54d41fc0fc8f8a89ec779696f3f7bb46e (patch) | |
tree | 86d15743ba85a3a6ba0a66641d66506946056a67 /src | |
parent | fdb6b4d2e729211f0526ce75c6a3fcc636859bfd (diff) | |
download | rneovim-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')
-rw-r--r-- | src/nvim/insexpand.c | 14 | ||||
-rw-r--r-- | src/nvim/testdir/test_ins_complete.vim | 48 |
2 files changed, 55 insertions, 7 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 6de3b0a9d0..8928979455 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -2096,10 +2096,10 @@ bool ins_compl_prep(int c) edit_submode_extra = NULL; } - // Ignore end of Select mode mapping and mouse scroll buttons. + // Ignore end of Select mode mapping and mouse scroll/movement. if (c == K_SELECT || c == K_MOUSEDOWN || c == K_MOUSEUP - || c == K_MOUSELEFT || c == K_MOUSERIGHT || c == K_EVENT - || c == K_COMMAND || c == K_LUA) { + || c == K_MOUSELEFT || c == K_MOUSERIGHT || c == K_MOUSEMOVE + || c == K_EVENT || c == K_COMMAND || c == K_LUA) { return retval; } @@ -3043,8 +3043,8 @@ static void get_next_spell_completion(linenr_T lnum) /// @param cur_match_pos current match position /// @param match_len /// @param cont_s_ipos next ^X<> will set initial_pos -static char *ins_comp_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_pos, int *match_len, - bool *cont_s_ipos) +static char *ins_compl_get_next_word_or_line(buf_T *ins_buf, pos_T *cur_match_pos, int *match_len, + bool *cont_s_ipos) { *match_len = 0; char *ptr = ml_get_buf(ins_buf, cur_match_pos->lnum, false) + cur_match_pos->col; @@ -3206,8 +3206,8 @@ static int get_next_default_completion(ins_compl_next_state_T *st, pos_T *start_ continue; } int len; - char *ptr = ins_comp_get_next_word_or_line(st->ins_buf, st->cur_match_pos, - &len, &cont_s_ipos); + char *ptr = ins_compl_get_next_word_or_line(st->ins_buf, st->cur_match_pos, + &len, &cont_s_ipos); if (ptr == NULL) { continue; } 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() |