Skip to content

Commit

Permalink
avoid duplicate remote_refresh by ignoring first TextChangedP
Browse files Browse the repository at this point in the history
  • Loading branch information
prabirshrestha committed Mar 16, 2018
1 parent aa3ad0d commit 720be50
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions autoload/asyncomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ endif

let s:sources = {}
let s:change_timer = -1
let s:on_changed_p = 0
let s:last_tick = []
let s:has_popped_up = 0
let s:complete_timer_ctx = {}
Expand Down Expand Up @@ -42,7 +43,7 @@ function! asyncomplete#enable_for_buffer() abort
autocmd InsertEnter <buffer> call s:remote_insert_enter()
autocmd InsertLeave <buffer> call s:remote_insert_leave()
autocmd TextChangedI <buffer> call s:on_changed()
autocmd TextChangedP <buffer> call s:on_changed()
autocmd TextChangedP <buffer> call s:on_changed_p()
augroup END
else
augroup ayncomplete
Expand Down Expand Up @@ -152,7 +153,7 @@ function! s:change_tick_stop() abort
let s:change_timer = -1
endfunction

function! s:on_changed() abort
function! s:on_changed_common() abort
if !get(b:, 'asyncomplete_enable') || mode() isnot# 'i' || &paste
return
endif
Expand All @@ -167,6 +168,21 @@ function! s:on_changed() abort
call s:remote_refresh(l:ctx, 0)
endfunction

function! s:on_changed() abort
let s:on_changed_p = 0
call s:on_changed_common()
endfunction

function! s:on_changed_p() abort
if s:on_changed_p == 0
" avoid duplicate remote_refresh by ignoring first TextChangedP
let s:on_changed_p = 1
return
endif

call s:on_changed_common()
endfunction

function! s:check_changes(...) abort
let l:tick = s:change_tick()
if l:tick != s:last_tick
Expand Down

0 comments on commit 720be50

Please sign in to comment.