Fix: iMap <Cr> Interfere in completion (alias popup-menu, pum) (Issue: #813)

Problem: When pum opened, the mapping of <CR> is triggered but user
want the default behaviour: to choose a completion item

Solution: Conditional mapping:
inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : ':<Esc>:VimwikiReturn 1 5<Cr>'
                         The previous mapping  -----------------^
This commit is contained in:
Tinmarino 2020-08-05 12:05:39 -04:00
parent 8cc99c00c2
commit e4186adc3d
3 changed files with 26 additions and 5 deletions

View File

@ -3717,7 +3717,6 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from
https://github.com/vimwiki-backup/vimwiki/issues. https://github.com/vimwiki-backup/vimwiki/issues.
New:~ New:~
* Issue #209: Feature: Markdown: Support SetExt Heading * Issue #209: Feature: Markdown: Support SetExt Heading
* Issue #847 #640: Feature: Markdown anchor * Issue #847 #640: Feature: Markdown anchor
normalize and unormalize: better follow_link and |VimwikiTOC| normalize and unormalize: better follow_link and |VimwikiTOC|
@ -3744,6 +3743,7 @@ Changed:~
Removed:~ Removed:~
Fixed:~ Fixed:~
* Issue #813: iMap <Cr> interfere with completion (pum)
* Issue #709: Support inline code spans inside emphasis * Issue #709: Support inline code spans inside emphasis
Refactoring code, del, eq, sup, sub as regions Refactoring code, del, eq, sup, sub as regions
* Issue #847 #640: Refactor: Syntax highlighting typeface: match -> region * Issue #847 #640: Refactor: Syntax highlighting typeface: match -> region

View File

@ -501,17 +501,18 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists)
call vimwiki#u#map_key('n', 'o', '<Plug>VimwikiListo') call vimwiki#u#map_key('n', 'o', '<Plug>VimwikiListo')
call vimwiki#u#map_key('n', 'O', '<Plug>VimwikiListO') call vimwiki#u#map_key('n', 'O', '<Plug>VimwikiListO')
" handle case of existing VimwikiReturn mappings outside the <Plug> definition " Handle case of existing VimwikiReturn mappings outside the <Plug> definition
" Note: Avoid interfering with popup/completion menu if it's active (#813)
if maparg('<CR>', 'i') !~# '.*VimwikiReturn*.' if maparg('<CR>', 'i') !~# '.*VimwikiReturn*.'
if has('patch-7.3.489') if has('patch-7.3.489')
" expand iabbrev on enter " expand iabbrev on enter
inoremap <silent><buffer> <CR> <C-]><Esc>:VimwikiReturn 1 5<CR> inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<C-]><Esc>:VimwikiReturn 1 5<CR>'
else else
inoremap <silent><buffer> <CR> <Esc>:VimwikiReturn 1 5<CR> inoremap <expr><silent><buffer> <CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 1 5<CR>'
endif endif
endif endif
if maparg('<S-CR>', 'i') !~# '.*VimwikiReturn*.' if maparg('<S-CR>', 'i') !~# '.*VimwikiReturn*.'
inoremap <silent><buffer> <S-CR> <Esc>:VimwikiReturn 2 2<CR> inoremap <expr><silent><buffer> <S-CR> pumvisible() ? '<CR>' : '<Esc>:VimwikiReturn 2 2<CR>'
endif endif
" change symbol for bulleted lists " change symbol for bulleted lists

View File

@ -114,9 +114,11 @@ Do (,w,m -> open tomorrow [Assert]):
Execute (===========================================================): Execute (===========================================================):
Log "Checking local map" Log "Checking local map"
# 2.1 Heading {{{2 # 2.1 Heading {{{2
############## ##############
Do (,wn -> Create new wiki [Assert]): Do (,wn -> Create new wiki [Assert]):
,wn ,wn
new_file1 new_file1
@ -293,6 +295,24 @@ Expect (Dec header level):
# 2.2 List {{{2 # 2.2 List {{{2
############## ##############
Given vimwiki (Completion list #813 {{{3):
complete1
complete2
complete3
Do (Insert a list item and complete):
Go
* comp\<C-n>\<Down>\<Cr>
Expect (With a completion but no new item):
complete1
complete2
complete3
* complete2
Given (Number list): Given (Number list):
1. I 1. I
1. Relly 1. Relly