From 32e22e64c613142eda6e7a93b34d073eda901aa7 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Tue, 26 Oct 2021 15:02:10 +0300 Subject: [PATCH] fix an error when calling cmp#unregister_source from Vimscript (#413) --- autoload/cmp.vim | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/autoload/cmp.vim b/autoload/cmp.vim index b74cffb..8fcdeeb 100644 --- a/autoload/cmp.vim +++ b/autoload/cmp.vim @@ -35,12 +35,9 @@ endfunction " cmp#unregister_source " function! cmp#unregister_source(id) abort - for [l:i, l:source] in s:sources - if l:source.id == a:id - call remove(s:sources, index(s:sources, l:source)) - break - endif - endfor + if has_key(s:sources, a:id) + unlet s:sources[a:id] + endif call luaeval('require("cmp").unregister_source(_A)', a:id) endfunction @@ -77,4 +74,3 @@ endfunction function! s:callback(id) abort return { ... -> luaeval('require("cmp.vim_source").on_callback(_A[1], _A[2])', [a:id, a:000]) } endfunction -