diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-25 07:52:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 07:52:35 +0800 |
commit | 4cf1bcf1836a8f8fc89425a4c83b9975583a5f28 (patch) | |
tree | 0a2a522f4a01562d571809ed58f42a0d203f505c /src | |
parent | 2caf5bbbc58fcc9830cd3f8a6110b66040c6e660 (diff) | |
parent | 48a35106efefa8f74d850d3eac365dc76b008ca3 (diff) | |
download | rneovim-4cf1bcf1836a8f8fc89425a4c83b9975583a5f28.tar.gz rneovim-4cf1bcf1836a8f8fc89425a4c83b9975583a5f28.tar.bz2 rneovim-4cf1bcf1836a8f8fc89425a4c83b9975583a5f28.zip |
Merge pull request #18248 from zeertzjq/vim-8.2.4806
vim-patch:8.2.{4806,4818}: a mapping using <LeftDrag> does not start Select mode
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/normal.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_mapping.vim | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d0926e6b9e..ed5f13d00a 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5740,10 +5740,10 @@ void start_selection(void) } /// Start Select mode, if "c" is in 'selectmode' and not in a mapping or menu. +/// When "c" is 'o' (checking for "mouse") then also when mapped. void may_start_select(int c) { - VIsual_select = (stuff_empty() && typebuf_typed() - && (vim_strchr(p_slm, c) != NULL)); + VIsual_select = (c == 'o' || (stuff_empty() && typebuf_typed())) && vim_strchr(p_slm, c) != NULL; } /// Start Visual mode "c". 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 |