Don't call complete() if startcol would be invalid.
I see a lot of preprocess_complete with `start_col=0` but I see some
without, so I guess those are the firings with valid data.
Not entirely sure what causes this, but it occurs often when doing
completion with omnisharp. I often get this error while typing or
triggering completion. I'd rather nothing happen than error spam, so
silence it.
Example callstack caused from explicit triggering of completion:
OmniSharp#Complete[10]
OmniSharp#actions#complete#Get[13]
<SNR>281_recompute_pum[44]
<SNR>281_default_preprocessor[34]
asyncomplete#preprocess_complete[16]
E578: Not allowed to change text here
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
```text
Error detected while processing function <SNR>244_recompute_pum[44]..<SNR>244_default_preprocessor[18]..<SNR>244_strip_pair_characters:
line 7:
E118: Too many arguments for function: copy
```
* Remove "skip popup" related logic
* Fix matches not getting cleared
Before this commit we don't clear the matches when the text
under the cursor is no longer suitable for completion. This
causes e.g. removing everything using <BS> does not close
the completion menu.
* Allow closing popup menu
Closing popup menu calls completion itself, making it
impossible to be successful.
We used to have a "skip popup" logic to fix this. It was
removed 2 commits ago for being too confusing.
To fix this a check is adapted to make sure that completion
is only called when the completion context has changed.
Since closing popup menu does not change the completion
context, it no longer calls completion, and therefore can
succeed.
Previously this check lets us not complete when we move to a
different line we are in insert mode, through for example
<CR> or <BS>, but actually we are not afraid of this. When
we enter a newline, we don't complete anyway since the
refresh pattern is not matched, and when we backspace to a
previous line, and the line happens to end with something
that will trigger a completion, why do we not want to
trigger it?
* Also compare completion base to determine context change
It is possible that in some situation changing the text under the
cursor does not change the position of the cursor, so we also
compare the completion base to determine whether the context has
changed.
* Remove "skip popup" related logic
* Fix matches not getting cleared
Before this commit we don't clear the matches when the text
under the cursor is no longer suitable for completion. This
causes e.g. removing everything using <BS> does not close
the completion menu.
* Add setting for minimum string length to trigger auto popup
* Use ternary
* Use simplified function
* Fix bug in new return function
* Add documentation for min_chars
* Add buffer override for min_chars
plugin/asyncomplete.vim sets up an autocmd to invoke
asyncomplete#enable_for_buffer() for every BufEnter. If we don't clear
this autocmd, then it will try to call that function, which will try to
source the autoload file, which outputs the error again.
Clearing that autocmd group stops the cycle and limits the number of
warnings to one.