mirror of
https://github.com/prabirshrestha/asyncomplete.vim.git
synced 2025-12-14 20:35:41 +01:00
Prevent errors from undefined s:previous_context (#251)
Prevent errors processing textchanged that don't come from insert mode.
When using asyncomplete with vim-ripple, I get these errors:
Error detected while processing TextChangedI Autocommands for "*"..function <SNR>43_on_text_changed_i[1]..<SNR>43_maybe_notify_on_change:
line 15:
E121: Undefined variable: s:previous_context
Error detected while processing InsertLeave Autocommands for "*"..function <SNR>43_on_insert_leave:
line 1:
E108: No such variable: "s:previous_context"
ripple uses :startinsert, but I can't replicate the error with just that
command. Not sure what's wrong, but this seems like a reasonable fix.
Plugins
=======
asyncomplete
ripple
Repro
=====
Hit CR when on a blank line:
gvim +"RippleCreate lua"
down arrow
CR
This commit is contained in:
@@ -41,7 +41,7 @@ function! s:on_insert_enter() abort
|
||||
endfunction
|
||||
|
||||
function! s:on_insert_leave() abort
|
||||
unlet s:previous_context
|
||||
unlet! s:previous_context
|
||||
endfunction
|
||||
|
||||
function! s:on_text_changed_i() abort
|
||||
@@ -53,6 +53,9 @@ function! s:on_text_changed_p() abort
|
||||
endfunction
|
||||
|
||||
function! s:maybe_notify_on_change() abort
|
||||
if !exists('s:previous_context')
|
||||
return
|
||||
endif
|
||||
" We notify on_change callbacks only when the cursor position
|
||||
" has changed.
|
||||
" Unfortunatelly we need this check because in insert mode it
|
||||
|
||||
Reference in New Issue
Block a user