diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 22:11:23 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-16 22:11:23 +0800 |
commit | 12b087704082f6d2278c8eb06bd9ac3e7f014c1a (patch) | |
tree | 9ff1a55f036a0c125adf9eaf914c1324b236b3ad /script | |
parent | fa518d4f9522b38aca9478ac494e9523cca475f3 (diff) | |
download | lua-language-server-12b087704082f6d2278c8eb06bd9ac3e7f014c1a.zip |
fix #1061
Diffstat (limited to 'script')
-rw-r--r-- | script/core/completion/completion.lua | 7 | ||||
-rw-r--r-- | script/core/hover/description.lua | 4 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 3 | ||||
-rw-r--r-- | script/vm/infer.lua | 3 |
4 files changed, 12 insertions, 5 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index c257643d..beff594c 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1121,9 +1121,10 @@ local function checkTypingEnum(state, position, defs, str, results) local enums = {} for _, def in ipairs(defs) do if def.type == 'doc.type.string' - or def.type == 'doc.type.integer' then + or def.type == 'doc.type.integer' + or def.type == 'doc.type.boolean' then enums[#enums+1] = { - label = util.viewLiteral(def[1]), + label = infer.viewObject(def), description = def.comment and def.comment.text, kind = define.CompletionItemKind.EnumMember, } @@ -1412,7 +1413,7 @@ local function tryCallArg(state, position, results) or src.type == 'doc.type.integer' or src.type == 'doc.type.boolean' then enums[#enums+1] = { - label = util.viewLiteral(src[1]), + label = infer.viewObject(src), description = src.comment, kind = define.CompletionItemKind.EnumMember, } diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index 5d350cf7..03f6128a 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -171,11 +171,11 @@ local function buildEnumChunk(docType, name) end lines[#lines+1] = ('%s:'):format(name) for _, enum in ipairs(enums) do - local enumDes = (' %s %q'):format( + local enumDes = (' %s %s'):format( (enum.default and '->') or (enum.additional and '+>') or ' |', - enum[1] + infer.viewObject(enum) ) if enum.comment then local first = true diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index b46c81d9..5a2e1d09 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -558,10 +558,12 @@ local function parseString(parent) end nextToken() + local mark = getMark() -- compatibility if content:sub(1, 1) == '"' or content:sub(1, 1) == "'" then if content:sub(1, 1) == content:sub(-1, -1) then + mark = content:sub(1, 1) content = content:sub(2, -2) end end @@ -571,6 +573,7 @@ local function parseString(parent) finish = getFinish(), parent = parent, [1] = content, + [2] = mark, } return str end diff --git a/script/vm/infer.lua b/script/vm/infer.lua index a47783f7..2a64ed52 100644 --- a/script/vm/infer.lua +++ b/script/vm/infer.lua @@ -128,6 +128,9 @@ local viewNodeSwitch = util.switch() infer._hasTable = true end) : case 'doc.type.string' + : call(function (source, infer) + return util.viewString(source[1], source[2]) + end) : case 'doc.type.integer' : case 'doc.type.boolean' : call(function (source, infer) |