diff --git a/plugin/clang_complete.vim b/plugin/clang_complete.vim index 5302329c..113525f0 100644 --- a/plugin/clang_complete.vim +++ b/plugin/clang_complete.vim @@ -493,9 +493,9 @@ function! ClangComplete(findstart, base) augroup ClangComplete au CursorMovedI call TriggerSnippet() if exists('##CompleteDone') - au CompleteDone,InsertLeave call StopMonitoring() + au CompleteDone,InsertLeave call StopMonitoring('all') else - au InsertLeave call StopMonitoring() + au InsertLeave call StopMonitoring('all') endif augroup end let b:snippet_chosen = 0 @@ -524,7 +524,9 @@ function! s:HandlePossibleSelectionCtrlY() return "\" endfunction -function! s:StopMonitoring() +" what argument should be "cr" to restore mapping only or "all" to undo +" everything +function! s:StopMonitoring(what) if b:snippet_chosen call s:TriggerSnippet() return @@ -549,9 +551,17 @@ function! s:StopMonitoring() silent! execute substitute(g:clang_restore_cr_imap, '', s:old_snr, 'g') endif + if a:what == 'cr' + return + endif + silent! iunmap endif + if a:what == 'cr' + return + endif + augroup ClangComplete au! CursorMovedI,InsertLeave if exists('##CompleteDone') @@ -561,6 +571,8 @@ function! s:StopMonitoring() endfunction function! s:TriggerSnippet() + call s:StopMonitoring('cr') + " Dont bother doing anything until we're sure the user exited the menu if !b:snippet_chosen return @@ -568,7 +580,7 @@ function! s:TriggerSnippet() " Stop monitoring as we'll trigger a snippet let b:snippet_chosen = 0 - call s:StopMonitoring() + call s:StopMonitoring('all') " Trigger the snippet execute s:py_cmd 'snippetsTrigger()'