From 3b642df7cb6730f35342803089f2d6d495ddd554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 11 Apr 2022 19:03:11 +0800 Subject: fix #1037 --- script/core/completion/completion.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'script/core/completion/completion.lua') diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 27d1b20a..9f0c6695 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -420,7 +420,7 @@ local function checkModule(state, word, position, results) end local function checkFieldFromFieldToIndex(state, name, src, parent, word, startPos, position) - if type(name) == 'string' and name:match '^[%a_][%w_]*$' then + if name:match '^[%a_][%w_]*$' then return nil end local textEdit, additionalTextEdits @@ -493,7 +493,7 @@ local function checkFieldThen(state, name, src, word, startPos, position, parent kind = define.CompletionItemKind.Function end buildFunction(results, src, value, oop, { - label = tostring(name), + label = name, kind = kind, match = name:match '^[^(]+', insertText = name:match '^[^(]+', @@ -526,7 +526,7 @@ local function checkFieldThen(state, name, src, word, startPos, position, parent textEdit, additionalTextEdits = checkFieldFromFieldToIndex(state, name, src, parent, word, startPos, position) end results[#results+1] = { - label = tostring(name), + label = name, kind = kind, deprecated = vm.isDeprecated(src) or nil, textEdit = textEdit, @@ -554,6 +554,7 @@ local function checkFieldOfRefs(refs, state, word, startPos, position, parent, o if isSameSource(state, src, startPos) then goto CONTINUE end + name = tostring(name) if isGlobal and locals and locals[name] then goto CONTINUE end @@ -1376,7 +1377,9 @@ local function checkTableLiteralField(state, position, tbl, fields, results) if left then for _, field in ipairs(fields) do local name = guide.getKeyName(field) - if not mark[name] and matchKey(left, guide.getKeyName(field)) then + if name + and not mark[name] + and matchKey(left, tostring(name)) then results[#results+1] = { label = guide.getKeyName(field), kind = define.CompletionItemKind.Property, -- cgit v1.2.3