diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-11 19:03:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-11 19:03:11 +0800 |
commit | 3b642df7cb6730f35342803089f2d6d495ddd554 (patch) | |
tree | bc767efc6c1c12fcb17024217d3adfd844af9922 /script/core/completion/completion.lua | |
parent | 2e4f530b33467b94376321c7f9879f2a879429bb (diff) | |
download | lua-language-server-3b642df7cb6730f35342803089f2d6d495ddd554.zip |
fix #1037
Diffstat (limited to 'script/core/completion/completion.lua')
-rw-r--r-- | script/core/completion/completion.lua | 11 |
1 files changed, 7 insertions, 4 deletions
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, |