Skip to content

Commit

Permalink
Try to fix #559
Browse files Browse the repository at this point in the history
Looks like 72eabd5 partially
undone #427.
  • Loading branch information
xaizek committed Aug 13, 2018
1 parent 0918788 commit e9d3283
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions plugin/clang_complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,9 @@ function! ClangComplete(findstart, base)
augroup ClangComplete
au CursorMovedI <buffer> call <SID>TriggerSnippet()
if exists('##CompleteDone')
au CompleteDone,InsertLeave <buffer> call <SID>StopMonitoring()
au CompleteDone,InsertLeave <buffer> call <SID>StopMonitoring('all')
else
au InsertLeave <buffer> call <SID>StopMonitoring()
au InsertLeave <buffer> call <SID>StopMonitoring('all')
endif
augroup end
let b:snippet_chosen = 0
Expand Down Expand Up @@ -524,7 +524,9 @@ function! s:HandlePossibleSelectionCtrlY()
return "\<C-Y>"
endfunction

function! s:StopMonitoring()
" what argument should be "cr" to restore <cr> mapping only or "all" to undo
" everything
function! s:StopMonitoring(what)
if b:snippet_chosen
call s:TriggerSnippet()
return
Expand All @@ -549,9 +551,17 @@ function! s:StopMonitoring()
silent! execute substitute(g:clang_restore_cr_imap, '<SID>', s:old_snr, 'g')
endif

if a:what == 'cr'
return
endif

silent! iunmap <buffer> <C-Y>
endif

if a:what == 'cr'
return
endif

augroup ClangComplete
au! CursorMovedI,InsertLeave <buffer>
if exists('##CompleteDone')
Expand All @@ -561,14 +571,16 @@ 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
endif

" 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()'
Expand Down

0 comments on commit e9d3283

Please sign in to comment.