From c8fe8c5ea4b57b4fb0aaf022b94aa7377c5b7a60 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 25 Apr 2022 06:39:02 +0800 Subject: vim-patch:8.2.4806: a mapping using does not start Select mode Problem: A mapping using does not start Select mode. Solution: When checking for starting select mode with the mouse also do this when there is typeahead. (closes vim/vim#10249) https://github.com/vim/vim/commit/53ef5731480d8b5aa74137a09b3b164b436ed76b --- src/nvim/normal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') 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". -- cgit From 48a35106efefa8f74d850d3eac365dc76b008ca3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 25 Apr 2022 06:41:01 +0800 Subject: 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. --- src/nvim/testdir/test_mapping.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') 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 "\" + endfunc + func DragExpr() + call test_setmouse(1, 2) + return "\" + endfunc + nnoremap ClickExpr() + nmap DragExpr() + + nnoremap + exe "normal \\" + call assert_equal('s', mode()) + exe "normal! \\" + + nunmap + nunmap + nunmap + delfunc ClickExpr + delfunc DragExpr + set selectmode& + set mouse& +endfunc + " Test for mapping in Insert mode func Test_mouse_drag_insert_map() CheckFunction test_setmouse -- cgit