diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-15 14:58:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-15 14:58:57 +0800 |
commit | 0a86f339d0eea44404502ae4cda8022a2ea21f27 (patch) | |
tree | 39cab1bc9f638d76e9e81bd5101acbeafeff7fdb | |
parent | dc2cb90f2b22b67b8cebc4996cec4f6c3e5c37dd (diff) | |
download | lua-language-server-0a86f339d0eea44404502ae4cda8022a2ea21f27.zip |
fix #598
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/completion.lua | 2 | ||||
-rw-r--r-- | script/core/hover/label.lua | 6 | ||||
-rw-r--r-- | script/core/hover/name.lua | 7 | ||||
-rw-r--r-- | test/hover/init.lua | 7 |
5 files changed, 17 insertions, 6 deletions
diff --git a/changelog.md b/changelog.md index 4dcf075f..bd39ed9b 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ * `FIX` completion: displaying `@fenv` in `Lua 5.1` * `FIX` [#596](https://github.com/sumneko/lua-language-server/issues/596) * `FIX` [#597](https://github.com/sumneko/lua-language-server/issues/597) +* `FIX` [#598](https://github.com/sumneko/lua-language-server/issues/598) ## 2.2.3 `2021-7-9` diff --git a/script/core/completion.lua b/script/core/completion.lua index 7a60ab69..f2eb3356 100644 --- a/script/core/completion.lua +++ b/script/core/completion.lua @@ -133,7 +133,7 @@ local function findParentInStringIndex(ast, text, offset) end local function buildFunctionSnip(source, value, oop) - local name = getName(source):gsub('^.+[$.:]', '') + local name = (getName(source) or ''):gsub('^.+[$.:]', '') local args = getArg(value, oop) local id = 0 args = args:gsub('[^,]+', function (arg) diff --git a/script/core/hover/label.lua b/script/core/hover/label.lua index 15cd2af9..434eaff1 100644 --- a/script/core/hover/label.lua +++ b/script/core/hover/label.lua @@ -16,7 +16,7 @@ local function asFunction(source, oop) local arg = buildArg(source, oop) local rtn = buildReturn(source) local lines = {} - lines[1] = ('function %s(%s)'):format(name, arg) + lines[1] = ('function %s(%s)'):format(name or '', arg) lines[2] = rtn return table.concat(lines, '\n') end @@ -26,7 +26,7 @@ local function asDocFunction(source) local arg = buildArg(source) local rtn = buildReturn(source) local lines = {} - lines[1] = ('function %s(%s)'):format(name, arg) + lines[1] = ('function %s(%s)'):format(name or '', arg) lines[2] = rtn return table.concat(lines, '\n') end @@ -45,7 +45,7 @@ local function asDocTypeName(source) end local function asValue(source, title) - local name = buildName(source, false) + local name = buildName(source, false) or '' local type = infer.searchAndViewInfers(source) local literal = infer.searchAndViewLiterals(source) local cont diff --git a/script/core/hover/name.lua b/script/core/hover/name.lua index d2b9d30b..49260e8f 100644 --- a/script/core/hover/name.lua +++ b/script/core/hover/name.lua @@ -23,7 +23,10 @@ local function asField(source, oop) if source.node.type ~= 'getglobal' then class = infer.getClass(source.node) end - local node = class or guide.getKeyName(source.node) or '?' + local node = class + or buildName(source.node, false) + or guide.getKeyName(source.node) + or '?' local method = guide.getKeyName(source) if oop then return ('%s:%s'):format(node, method) @@ -100,7 +103,7 @@ function buildName(source, oop) if parent then return buildName(parent, oop) end - return '', oop + return nil, oop end return buildName diff --git a/test/hover/init.lua b/test/hover/init.lua index 18482de5..4f339c87 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1664,3 +1664,10 @@ local t: { [10]: string = "d", } ]] + +TEST [[ +function f1.f2.<?f3?>() end +]] +[[ +function f1.f2.f3() +]] |