mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
feat(mappings): do not replace existing mapping for simplified form
This commit is contained in:
@@ -365,6 +365,10 @@ Macro/|recording| behavior
|
||||
macros and 'keymap' at the same time. This also means you can use |:imap| on
|
||||
the results of keys from 'keymap'.
|
||||
|
||||
Mappings:
|
||||
Creating a mapping for a simplifiable key (e.g. <C-I>) doesn't replace an
|
||||
existing mapping for its simplified form (e.g. <Tab>).
|
||||
|
||||
Motion:
|
||||
The |jumplist| avoids useless/phantom jumps.
|
||||
|
||||
|
@@ -3279,6 +3279,11 @@ int buf_do_map(int maptype, MapArguments *args, int mode, bool is_abbrev, buf_T
|
||||
} else if (n != len) { // new entry is ambiguous
|
||||
mpp = &(mp->m_next);
|
||||
continue;
|
||||
} else if (keyround1_simplified && !mp->m_simplified) {
|
||||
// In keyround for simplified keys, don't replace
|
||||
// a mapping without m_simplified flag.
|
||||
did_it = true;
|
||||
break;
|
||||
} else if (args->unique) {
|
||||
if (is_abbrev) {
|
||||
semsg(_("E226: abbreviation already exists for %s"), p);
|
||||
|
@@ -173,13 +173,22 @@ describe('input pairs', function()
|
||||
eq('\t\t', curbuf_contents())
|
||||
end)
|
||||
|
||||
it('can be mapped', function()
|
||||
describe('can be mapped separately', function()
|
||||
it('if <tab> is mapped after <c-i>', function()
|
||||
command('inoremap <c-i> CTRL-I!')
|
||||
command('inoremap <tab> TAB!')
|
||||
feed('i<tab><c-i><esc>')
|
||||
eq('TAB!CTRL-I!', curbuf_contents())
|
||||
end)
|
||||
|
||||
it('if <tab> is mapped before <c-i>', function()
|
||||
command('inoremap <tab> TAB!')
|
||||
command('inoremap <c-i> CTRL-I!')
|
||||
feed('i<tab><c-i><esc>')
|
||||
eq('TAB!CTRL-I!', curbuf_contents())
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('<cr> / <c-m>', function()
|
||||
it('ok', function()
|
||||
@@ -187,12 +196,21 @@ describe('input pairs', function()
|
||||
eq('unos\ndos\ntres', curbuf_contents())
|
||||
end)
|
||||
|
||||
it('can be mapped', function()
|
||||
describe('can be mapped separately', function()
|
||||
it('if <cr> is mapped after <c-m>', function()
|
||||
command('inoremap <c-m> SNIPPET!')
|
||||
command('inoremap <cr> , and then<cr>')
|
||||
feed('iunos<c-m>dos<cr>tres<esc>')
|
||||
eq('unosSNIPPET!dos, and then\ntres', curbuf_contents())
|
||||
end)
|
||||
|
||||
it('if <cr> is mapped before <c-m>', function()
|
||||
command('inoremap <cr> , and then<cr>')
|
||||
command('inoremap <c-m> SNIPPET!')
|
||||
feed('iunos<c-m>dos<cr>tres<esc>')
|
||||
eq('unosSNIPPET!dos, and then\ntres', curbuf_contents())
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('<esc> / <c-[>', function()
|
||||
@@ -201,12 +219,21 @@ describe('input pairs', function()
|
||||
eq('doubledoublesingle', curbuf_contents())
|
||||
end)
|
||||
|
||||
it('can be mapped', function()
|
||||
describe('can be mapped separately', function()
|
||||
it('if <esc> is mapped after <c-[>', function()
|
||||
command('inoremap <c-[> HALLOJ!')
|
||||
command('inoremap <esc> ,<esc>')
|
||||
feed('2adubbel<c-[>upp<esc>')
|
||||
eq('dubbelHALLOJ!upp,dubbelHALLOJ!upp,', curbuf_contents())
|
||||
end)
|
||||
|
||||
it('if <esc> is mapped before <c-[>', function()
|
||||
command('inoremap <esc> ,<esc>')
|
||||
command('inoremap <c-[> HALLOJ!')
|
||||
feed('2adubbel<c-[>upp<esc>')
|
||||
eq('dubbelHALLOJ!upp,dubbelHALLOJ!upp,', curbuf_contents())
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Reference in New Issue
Block a user