@@ -315,7 +315,7 @@ local function checkLocal(state, word, position, results)
315315 return orders [a ] < orders [b ]
316316 end )
317317 for _ , def in ipairs (defs ) do
318- if def .type == ' function'
318+ if ( def .type == ' function' and not vm . isVarargFunctionWithOverloads ( def ))
319319 or def .type == ' doc.type.function' then
320320 local funcLabel = name .. getParams (def , false )
321321 buildFunction (results , source , def , false , {
@@ -364,7 +364,7 @@ local function checkModule(state, word, position, results)
364364 if not locals [stemName ]
365365 and not vm .hasGlobalSets (state .uri , ' variable' , stemName )
366366 and not globals [stemName ]
367- and stemName :match ' ^[%a_][%w_]*$ '
367+ and stemName :match ( guide . namePatternFull )
368368 and matchKey (word , stemName ) then
369369 local targetState = files .getState (uri )
370370 if not targetState then
@@ -422,8 +422,11 @@ local function checkModule(state, word, position, results)
422422end
423423
424424local function checkFieldFromFieldToIndex (state , name , src , parent , word , startPos , position )
425- if name :match ' ^[%a_][%w_]*$' then
426- return nil
425+ if name :match (guide .namePatternFull ) then
426+ if not name :match ' [\x80 -\xff ]'
427+ or config .get (state .uri , ' Lua.runtime.unicodeName' ) then
428+ return nil
429+ end
427430 end
428431 local textEdit , additionalTextEdits
429432 local startOffset = guide .positionToOffset (state , startPos )
@@ -474,8 +477,8 @@ local function checkFieldFromFieldToIndex(state, name, src, parent, word, startP
474477 }
475478 end
476479 else
477- if config .get (state .uri , ' Lua.runtime.version' ) == ' lua 5.1'
478- or config .get (state .uri , ' Lua.runtime.version' ) == ' luaJIT ' then
480+ if config .get (state .uri , ' Lua.runtime.version' ) == ' Lua 5.1'
481+ or config .get (state .uri , ' Lua.runtime.version' ) == ' LuaJIT ' then
479482 textEdit .newText = ' _G' .. textEdit .newText
480483 else
481484 textEdit .newText = ' _ENV' .. textEdit .newText
487490local function checkFieldThen (state , name , src , word , startPos , position , parent , oop , results )
488491 local value = vm .getObjectFunctionValue (src ) or src
489492 local kind = define .CompletionItemKind .Field
490- if value .type == ' function'
493+ if ( value .type == ' function' and not vm . isVarargFunctionWithOverloads ( value ))
491494 or value .type == ' doc.type.function' then
492495 if oop then
493496 kind = define .CompletionItemKind .Method
@@ -569,9 +572,11 @@ local function checkFieldOfRefs(refs, state, word, startPos, position, parent, o
569572 local value = vm .getObjectFunctionValue (src ) or src
570573 if value .type == ' function'
571574 or value .type == ' doc.type.function' then
572- funcLabel = name .. getParams (value , oop )
573- fields [funcLabel ] = src
574- count = count + 1
575+ if not vm .isVarargFunctionWithOverloads (value ) then
576+ funcLabel = name .. getParams (value , oop )
577+ fields [funcLabel ] = src
578+ count = count + 1
579+ end
575580 if value .type == ' function' and value .bindDocs then
576581 for _ , doc in ipairs (value .bindDocs ) do
577582 if doc .type == ' doc.overload' then
@@ -726,7 +731,7 @@ local function checkCommon(state, word, position, results)
726731 end
727732 end
728733 end
729- for str , offset in state .lua :gmatch ' ([%a_][%w_]+ )()' do
734+ for str , offset in state .lua :gmatch ( ' ( ' .. guide . namePattern .. ' )()' ) do
730735 if # results >= 100 then
731736 results .incomplete = true
732737 break
0 commit comments