From e4186adc3df6c464643dd5c364a8b42e75fc844a Mon Sep 17 00:00:00 2001 From: Tinmarino Date: Wed, 5 Aug 2020 12:05:39 -0400 Subject: [PATCH] Fix: iMap Interfere in completion (alias popup-menu, pum) (Issue: #813) Problem: When pum opened, the mapping of is triggered but user want the default behaviour: to choose a completion item Solution: Conditional mapping: inoremap pumvisible() ? '' : '::VimwikiReturn 1 5' The previous mapping -----------------^ --- doc/vimwiki.txt | 2 +- ftplugin/vimwiki.vim | 9 +++++---- test/independent_runs/map.vader | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index 706ca43..4ed030c 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -3717,7 +3717,6 @@ http://code.google.com/p/vimwiki/issues/list. They may be accessible from https://github.com/vimwiki-backup/vimwiki/issues. New:~ - * Issue #209: Feature: Markdown: Support SetExt Heading * Issue #847 #640: Feature: Markdown anchor normalize and unormalize: better follow_link and |VimwikiTOC| @@ -3744,6 +3743,7 @@ Changed:~ Removed:~ Fixed:~ + * Issue #813: iMap interfere with completion (pum) * Issue #709: Support inline code spans inside emphasis Refactoring code, del, eq, sup, sub as regions * Issue #847 #640: Refactor: Syntax highlighting typeface: match -> region diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 97a2e08..353f15a 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -501,17 +501,18 @@ if str2nr(vimwiki#vars#get_global('key_mappings').lists) call vimwiki#u#map_key('n', 'o', 'VimwikiListo') call vimwiki#u#map_key('n', 'O', 'VimwikiListO') - " handle case of existing VimwikiReturn mappings outside the definition + " Handle case of existing VimwikiReturn mappings outside the definition + " Note: Avoid interfering with popup/completion menu if it's active (#813) if maparg('', 'i') !~# '.*VimwikiReturn*.' if has('patch-7.3.489') " expand iabbrev on enter - inoremap :VimwikiReturn 1 5 + inoremap pumvisible() ? '' : ':VimwikiReturn 1 5' else - inoremap :VimwikiReturn 1 5 + inoremap pumvisible() ? '' : ':VimwikiReturn 1 5' endif endif if maparg('', 'i') !~# '.*VimwikiReturn*.' - inoremap :VimwikiReturn 2 2 + inoremap pumvisible() ? '' : ':VimwikiReturn 2 2' endif " change symbol for bulleted lists diff --git a/test/independent_runs/map.vader b/test/independent_runs/map.vader index 1f772e5..f7d4e24 100644 --- a/test/independent_runs/map.vader +++ b/test/independent_runs/map.vader @@ -114,9 +114,11 @@ Do (,w,m -> open tomorrow [Assert]): Execute (===========================================================): Log "Checking local map" + # 2.1 Heading {{{2 ############## + Do (,wn -> Create new wiki [Assert]): ,wn new_file1 @@ -293,6 +295,24 @@ Expect (Dec header level): # 2.2 List {{{2 ############## + + +Given vimwiki (Completion list #813 {{{3): + complete1 + complete2 + complete3 + +Do (Insert a list item and complete): + Go + * comp\\\ + +Expect (With a completion but no new item): + complete1 + complete2 + complete3 + * complete2 + + Given (Number list): 1. I 1. Relly