@@ -3,7 +3,7 @@ vim9script noclear
33# Vim completion script
44# Language: C
55# Maintainer: The Vim Project <https://github.com/vim/vim>
6- # Last Change: 2025 Jul 23
6+ # Last Change: 2025 Jul 24
77# Rewritten in Vim9 script by github user lacygoill
88# Former Maintainer: Bram Moolenaar
<[email protected] > 99
@@ -82,9 +82,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
8282 var s: number = 0
8383 var arrays: number = 0
8484 while 1
85- if complete_check ()
86- return v: none
87- endif
8885 var e : number = base- >charidx (match (base, ' \.\|->\|\[' , s ))
8986 if e < 0
9087 if s == 0 || base[s - 1 ] != ' ]'
@@ -107,9 +104,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
107104 s = e
108105 ++ e
109106 while e < strcharlen (base)
110- if complete_check ()
111- return v: none
112- endif
113107 if base[e ] == ' ]'
114108 if n == 0
115109 break
@@ -146,7 +140,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
146140 var col2: number = col - 1
147141 while line [col2] != ' ;'
148142 if complete_check ()
149- return v: none
143+ return res
150144 endif
151145 -- col2
152146 endwhile
@@ -159,7 +153,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
159153 var col2: number = col - 1
160154 while line [col2] != ' ,'
161155 if complete_check ()
162- return v: none
156+ return res
163157 endif
164158 -- col2
165159 endwhile
@@ -200,10 +194,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
200194 endif
201195 endif
202196
203- if complete_check ()
204- return v: none
205- endif
206-
207197 if len (items ) == 1 || len (items ) == arrays + 1
208198 # Only one part, no "." or "->": complete from tags file.
209199 var tags : list <dict<any> >
@@ -226,10 +216,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
226216 res = res - >extend (tags - >map ((_, v: dict <any> ) = > Tag2item (v )))
227217 endif
228218
229- if complete_check ()
230- return v: none
231- endif
232-
233219 if len (res ) == 0
234220 # Find the variable in the tags file (s )
235221 var diclist: list <dict<any> > = taglist (' ^' .. items [0 ] .. ' $' )
@@ -240,7 +226,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
240226 res = []
241227 for i : number in len (diclist)- >range ()
242228 if complete_check ()
243- return []
229+ return res
244230 endif
245231 # New ctags has the " typeref" field. Patched version has " typename" .
246232 if diclist[i ]- >has_key (' typename' )
@@ -261,10 +247,6 @@ export def Complete(findstart: bool, abase: string): any # {{{1
261247 endfor
262248 endif
263249
264- if complete_check ()
265- return v: none
266- endif
267-
268250 if len (res ) == 0 && items [0 ]- >searchdecl (true) == 0
269251 # Found, now figure out the type .
270252 # TODO : join previous line if it makes sense
@@ -278,7 +260,7 @@ export def Complete(findstart: bool, abase: string): any # {{{1
278260 var brackets: string = ' '
279261 while last >= 0
280262 if complete_check ()
281- return v: none
263+ return res
282264 endif
283265 if items [last ][0 ] != ' ['
284266 break
@@ -346,7 +328,7 @@ def Dict2info(dict: dict<any>): string # {{{1
346328 var info: string = ' '
347329 for k : string in dict - >keys ()- >sort ()
348330 if complete_check ()
349- return " "
331+ return info
350332 endif
351333 info ..= k .. repeat (' ' , 10 - strlen (k ))
352334 if k == ' cmd'
@@ -384,7 +366,7 @@ def ParseTagline(line: string): dict<any> # {{{1
384366 endif
385367 for i : number in range (n + 1 , len (l ) - 1 )
386368 if complete_check ()
387- return {}
369+ return d
388370 endif
389371 if l [i ] == ' file:'
390372 d [' static' ] = 1
@@ -482,7 +464,7 @@ def Nextitem( # {{{1
482464 var res : list <dict<string> >
483465 for tidx: number in len (tokens)- >range ()
484466 if complete_check ()
485- return []
467+ return res
486468 endif
487469
488470 # Skip tokens starting with a non- ID character .
@@ -510,9 +492,11 @@ def Nextitem( # {{{1
510492 # Use the tags file to find out if this is a typedef .
511493 var diclist: list <dict<any> > = taglist (' ^' .. tokens[tidx] .. ' $' )
512494 for tagidx: number in len (diclist)- >range ()
513- if complete_check ()
514- return []
515- endif
495+
496+ if complete_check ()
497+ return res
498+ endif
499+
516500 var item: dict <any> = diclist[tagidx]
517501
518502 # New ctags has the " typeref" field. Patched version has " typename" .
@@ -672,7 +656,7 @@ def StructMembers( # {{{1
672656 ++ idx
673657 while 1
674658 if complete_check ()
675- return []
659+ return matches
676660 endif
677661 if idx >= len (items )
678662 return matches # No further items , return the result.
@@ -702,7 +686,7 @@ def SearchMembers( # {{{1
702686 var res : list <dict<string> >
703687 for i : number in len (matches)- >range ()
704688 if complete_check ()
705- return []
689+ return res
706690 endif
707691 var typename : string = ' '
708692 var line : string
0 commit comments