Prevent 'Not allowed to change text here' (#259)

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
This commit is contained in:
David Briscoe
2021-08-19 15:43:40 -07:00
committed by GitHub
parent 6c653c3f8f
commit 73ac8e4e45

View File

@@ -514,8 +514,11 @@ function! asyncomplete#preprocess_complete(ctx, items) abort
setl completeopt=menuone,noinsert,noselect
endif
call asyncomplete#log('core', 'asyncomplete#preprocess_complete calling complete()', a:ctx['startcol'], a:items)
call complete(a:ctx['startcol'], a:items)
let l:startcol = a:ctx['startcol']
call asyncomplete#log('core', 'asyncomplete#preprocess_complete calling complete()', l:startcol, a:items)
if l:startcol > 0 " Prevent E578: Not allowed to change text here
call complete(l:startcol, a:items)
endif
endfunction
function! asyncomplete#menu_selected() abort