0
0
mirror of https://github.com/vim/vim.git synced 2025-10-28 09:27:14 -04:00

patch 9.1.1603: completion: cannot use autoloaded funcs in 'complete' F{func}

Problem:  completion: cannot use autoloaded funcs in 'complete' F{func}
          (Maxim Kim)
Solution: Make it work (Girish Palya)

fixes: #17869
closes: #17885

Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Girish Palya
2025-08-08 12:30:35 +02:00
committed by Christian Brabandt
parent 7132935413
commit 1bfe86a7d3
10 changed files with 299 additions and 63 deletions

View File

@@ -198,6 +198,10 @@ func Test_omni_autoload()
setlocal omnifunc=omni#Func
call feedkeys("i\<C-X>\<C-O>\<Esc>", 'xt')
setlocal complete=.,Fomni#Func
call feedkeys("S\<C-N>\<Esc>", 'xt')
setlocal complete&
bwipe!
set omnifunc=
let &rtp = save_rtp
@@ -2692,6 +2696,15 @@ func Test_omnifunc_callback()
call assert_equal([[1, ''], [0, 'script1']], g:OmniFunc3Args)
bw!
set complete=Fs:OmniFunc3
new
call setline(1, 'script1')
let g:OmniFunc3Args = []
call feedkeys("A\<C-N>\<Esc>", 'x')
call assert_equal([[1, ''], [0, 'script1']], g:OmniFunc3Args)
bw!
set complete&
let &omnifunc = 's:OmniFunc3'
new
call setline(1, 'script2')
@@ -5323,4 +5336,51 @@ func Test_autocomplete_timer()
unlet g:CallCount
endfunc
func s:TestCompleteScriptLocal(findstart, base)
if a:findstart
return 1
else
return ['foo', 'foobar']
endif
endfunc
" Issue 17869
func Test_scriplocal_autoload_func()
let save_rtp = &rtp
set rtp=Xruntime/some
let dir = 'Xruntime/some/autoload'
call mkdir(dir, 'pR')
let lines =<< trim END
vim9script
export def Func(findstart: bool, base: string): any
if findstart
return 1
else
return ['match', 'matchfoo']
endif
enddef
END
call writefile(lines, dir .. '/compl.vim')
call test_override("char_avail", 1)
new
inoremap <buffer> <F2> <Cmd>let b:matches = complete_info(["matches"]).matches<CR>
set autocomplete
setlocal complete=.,Fcompl#Func
call feedkeys("im\<F2>\<Esc>0", 'xt!')
call assert_equal(['match', 'matchfoo'], b:matches->mapnew('v:val.word'))
setlocal complete=.,F<SID>TestCompleteScriptLocal
call feedkeys("Sf\<F2>\<Esc>0", 'xt!')
call assert_equal(['foo', 'foobar'], b:matches->mapnew('v:val.word'))
setlocal complete&
set autocomplete&
bwipe!
call test_override("char_avail", 0)
let &rtp = save_rtp
endfunc
" vim: shiftwidth=2 sts=2 expandtab nofoldenable

View File

@@ -281,11 +281,17 @@ func Test_complete()
set complete=.,w,b,u,k,s,i,d,],t,U,F,o
set complete=.
set complete=.^10,t^0
set complete+=Ffuncref('foo'\\,\ [10])
set complete=Ffuncref('foo'\\,\ [10])^10
func Foo(a, b)
return ''
endfunc
set complete+=Ffuncref('Foo'\\,\ [10])
set complete=Ffuncref('Foo'\\,\ [10])^10
set complete&
set complete+=Ffunction('g:foo'\\,\ [10\\,\ 20])
set complete+=Ffunction('g:Foo'\\,\ [10\\,\ 20])
set complete&
delfunc Foo
endfun
func Test_set_completion()