Skip to content

Commit

Permalink
fix: add conditions to autocmd using is_completed
Browse files Browse the repository at this point in the history
  • Loading branch information
kawarimidoll committed Nov 27, 2023
1 parent 3f27270 commit 0831062
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions k.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ function! s:capital(char) abort
return substitute(a:char, '.', '\U\0', '')
endfunction

function! s:is_completed() abort
return get(complete_info(), 'selected', -1) >= 0
endfunction

let s:is_enable = v:false
let s:keys_to_remaps = []
let s:keys_to_unmaps = []
Expand All @@ -22,9 +26,16 @@ function! k#enable() abort
augroup k_augroup
autocmd!
autocmd InsertLeave * call k#disable()
autocmd CompleteDonePre * call s:complete_done_pre(complete_info(), v:completed_item)
autocmd CompleteDonePre *
\ if s:is_completed()
\ | call s:complete_done_pre(complete_info(), v:completed_item)
\ | endif

if s:min_auto_complete_length > 0
autocmd TextChangedI,TextChangedP * call s:auto_complete()
autocmd TextChangedI,TextChangedP *
\ if !s:is_completed()
\ | call s:auto_complete()
\ | endif
endif
augroup END

Expand Down Expand Up @@ -489,11 +500,6 @@ endfunction
function! s:complete_done_pre(complete_info, completed_item) abort
" echomsg a:complete_info a:completed_item

if get(a:complete_info, 'selected', -1) < 0
" not selected
return
endif

if s:is_same_line_right_col('henkan')
" echomsg 'complete_done_pre clear_henkan_start_pos'
call s:clear_henkan_start_pos()
Expand Down

0 comments on commit 0831062

Please sign in to comment.