diff --git a/autoload/easycomplete.vim b/autoload/easycomplete.vim index 223b5fc..c4360b4 100644 --- a/autoload/easycomplete.vim +++ b/autoload/easycomplete.vim @@ -2091,6 +2091,7 @@ function! s:flush() call s:CloseCompletionMenu() endif let s:easycomplete_start_pos = 0 + let b:old_changedtick = 0 endfunction function! s:ResetCompletedItem() @@ -2346,7 +2347,11 @@ function! easycomplete#TextChangedI() if g:env_is_nvim && easycomplete#pum#visible() " TextChangedP " call s:RememberCtx() - doautocmd User easycomplete_pum_textchanged_p + if easycomplete#pum#InsertZizzing() + call easycomplete#pum#InsertAwake() + else + doautocmd User easycomplete_pum_textchanged_p + endif else " TextChangedI call easycomplete#tabnine#flush() @@ -2474,6 +2479,7 @@ function! easycomplete#BufEnter() endif call timer_start(1600, { -> easycomplete#lint() }) endif + call s:flush() endfunction function! easycomplete#finish() diff --git a/autoload/easycomplete/pum.vim b/autoload/easycomplete/pum.vim index d6b5bab..c1ea2b5 100644 --- a/autoload/easycomplete/pum.vim +++ b/autoload/easycomplete/pum.vim @@ -24,6 +24,9 @@ let s:default_scroll_bar_pot = { let s:pum_window = 0 let s:pum_buffer = 0 let s:pum_direction = "" +" Insert word 的动作会触发 TextChangedI → TextChangedP → TypingMatch +" 这里要让 TextChangedI 躲过去,设置一个标志位 +let s:pum_insert_word_timer = 0 " pum 高亮所需的临时样式 match id let g:easycomplete_match_id = 0 @@ -424,6 +427,7 @@ function! easycomplete#pum#SetWordBySelecting() let backing_count = cursor_left - pum_pos.pos[1] - 2 let oprator_str = repeat("\", backing_count) let word = get(s:curr_items[s:selected_i - 1], "word", "") + call s:insert_zizz() if !easycomplete#pum#CompleteCursored() return oprator_str . get(s:original_ctx, "typing", "") else @@ -462,6 +466,25 @@ function! s:InsertWord(word) execute 'noa set completeopt='.saved_completeopt endfunction +function! s:insert_zizz() + if easycomplete#pum#InsertZizzing() + call timer_stop(s:pum_insert_word_timer) + endif + let s:pum_insert_word_timer = timer_start(500, { -> s:insert_awake() }) +endfunction + +function! s:insert_awake() + let s:pum_insert_word_timer = 0 +endfunction + +function! easycomplete#pum#InsertAwake() + call s:insert_awake() +endfunction + +function! easycomplete#pum#InsertZizzing() + return s:pum_insert_word_timer > 0 +endfunction + function! easycomplete#pum#select(line_index) call s:select(a:line_index) endfunction