mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 03:05:11 -07:00
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
This commit is contained in:
commit
4cf1bcf183
@ -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".
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user