mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
vim-patch:8.2.4498: using <Plug> with "noremap" does not work
Problem: Using <Plug> with "noremap" does not work.
Solution: Always remap <Plug>. (closes vim/vim#9879, closes vim/vim#9789)
1fc34225ac
This commit is contained in:
parent
7211d8ef21
commit
e8107f0748
@ -65,8 +65,8 @@ modes.
|
|||||||
where the map command applies. Disallow mapping of
|
where the map command applies. Disallow mapping of
|
||||||
{rhs}, to avoid nested and recursive mappings. Often
|
{rhs}, to avoid nested and recursive mappings. Often
|
||||||
used to redefine a command.
|
used to redefine a command.
|
||||||
Note: A mapping whose {lhs} starts with <Plug> is
|
Note: When <Plug> appears in the {rhs} this part is
|
||||||
always applied even if mapping is disallowed.
|
always applied even if remapping is disallowed.
|
||||||
|
|
||||||
|
|
||||||
:unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap*
|
:unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap*
|
||||||
|
@ -358,10 +358,6 @@ Macro/|recording| behavior
|
|||||||
macros and 'keymap' at the same time. This also means you can use |:imap| on
|
macros and 'keymap' at the same time. This also means you can use |:imap| on
|
||||||
the results of keys from 'keymap'.
|
the results of keys from 'keymap'.
|
||||||
|
|
||||||
Mappings:
|
|
||||||
- A mapping whose {lhs} starts with <Plug> is always applied even if mapping
|
|
||||||
is disallowed by |nore|.
|
|
||||||
|
|
||||||
Motion:
|
Motion:
|
||||||
The |jumplist| avoids useless/phantom jumps.
|
The |jumplist| avoids useless/phantom jumps.
|
||||||
|
|
||||||
|
@ -1712,8 +1712,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)
|
|||||||
int local_State = get_real_state();
|
int local_State = get_real_state();
|
||||||
bool is_plug_map = false;
|
bool is_plug_map = false;
|
||||||
|
|
||||||
// Check if typehead starts with a <Plug> mapping.
|
// If typehead starts with <Plug> then remap, even for a "noremap" mapping.
|
||||||
// In that case we will ignore nore flag on it.
|
|
||||||
if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
|
if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL
|
||||||
&& typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA
|
&& typebuf.tb_buf[typebuf.tb_off + 1] == KS_EXTRA
|
||||||
&& typebuf.tb_buf[typebuf.tb_off + 2] == KE_PLUG) {
|
&& typebuf.tb_buf[typebuf.tb_off + 2] == KE_PLUG) {
|
||||||
|
@ -646,4 +646,34 @@ func Test_abbreviate_multi_byte()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for <Plug> always being mapped, even when used with "noremap".
|
||||||
|
func Test_plug_remap()
|
||||||
|
let g:foo = 0
|
||||||
|
nnoremap <Plug>(Increase_x) <Cmd>let g:foo += 1<CR>
|
||||||
|
nmap <F2> <Plug>(Increase_x)
|
||||||
|
nnoremap <F3> <Plug>(Increase_x)
|
||||||
|
call feedkeys("\<F2>", 'xt')
|
||||||
|
call assert_equal(1, g:foo)
|
||||||
|
call feedkeys("\<F3>", 'xt')
|
||||||
|
call assert_equal(2, g:foo)
|
||||||
|
nnoremap x <Nop>
|
||||||
|
nmap <F4> x<Plug>(Increase_x)x
|
||||||
|
nnoremap <F5> x<Plug>(Increase_x)x
|
||||||
|
call setline(1, 'Some text')
|
||||||
|
normal! gg$
|
||||||
|
call feedkeys("\<F4>", 'xt')
|
||||||
|
call assert_equal(3, g:foo)
|
||||||
|
call assert_equal('Some text', getline(1))
|
||||||
|
call feedkeys("\<F5>", 'xt')
|
||||||
|
call assert_equal(4, g:foo)
|
||||||
|
call assert_equal('Some te', getline(1))
|
||||||
|
nunmap <Plug>(Increase_x)
|
||||||
|
nunmap <F2>
|
||||||
|
nunmap <F3>
|
||||||
|
nunmap <F4>
|
||||||
|
nunmap <F5>
|
||||||
|
unlet g:foo
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user