Skip to content

Commit 0a86f33

Browse files
committed
fix #598
1 parent dc2cb90 commit 0a86f33

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* `FIX` completion: displaying `@fenv` in `Lua 5.1`
1111
* `FIX` [#596](https://github.com./sumneko/lua-language-server/issues/596)
1212
* `FIX` [#597](https://github.com./sumneko/lua-language-server/issues/597)
13+
* `FIX` [#598](https://github.com./sumneko/lua-language-server/issues/598)
1314

1415
## 2.2.3
1516
`2021-7-9`

script/core/completion.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ local function findParentInStringIndex(ast, text, offset)
133133
end
134134

135135
local function buildFunctionSnip(source, value, oop)
136-
local name = getName(source):gsub('^.+[$.:]', '')
136+
local name = (getName(source) or ''):gsub('^.+[$.:]', '')
137137
local args = getArg(value, oop)
138138
local id = 0
139139
args = args:gsub('[^,]+', function (arg)

script/core/hover/label.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ local function asFunction(source, oop)
1616
local arg = buildArg(source, oop)
1717
local rtn = buildReturn(source)
1818
local lines = {}
19-
lines[1] = ('function %s(%s)'):format(name, arg)
19+
lines[1] = ('function %s(%s)'):format(name or '', arg)
2020
lines[2] = rtn
2121
return table.concat(lines, '\n')
2222
end
@@ -26,7 +26,7 @@ local function asDocFunction(source)
2626
local arg = buildArg(source)
2727
local rtn = buildReturn(source)
2828
local lines = {}
29-
lines[1] = ('function %s(%s)'):format(name, arg)
29+
lines[1] = ('function %s(%s)'):format(name or '', arg)
3030
lines[2] = rtn
3131
return table.concat(lines, '\n')
3232
end
@@ -45,7 +45,7 @@ local function asDocTypeName(source)
4545
end
4646

4747
local function asValue(source, title)
48-
local name = buildName(source, false)
48+
local name = buildName(source, false) or ''
4949
local type = infer.searchAndViewInfers(source)
5050
local literal = infer.searchAndViewLiterals(source)
5151
local cont

script/core/hover/name.lua

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ local function asField(source, oop)
2323
if source.node.type ~= 'getglobal' then
2424
class = infer.getClass(source.node)
2525
end
26-
local node = class or guide.getKeyName(source.node) or '?'
26+
local node = class
27+
or buildName(source.node, false)
28+
or guide.getKeyName(source.node)
29+
or '?'
2730
local method = guide.getKeyName(source)
2831
if oop then
2932
return ('%s:%s'):format(node, method)
@@ -100,7 +103,7 @@ function buildName(source, oop)
100103
if parent then
101104
return buildName(parent, oop)
102105
end
103-
return '', oop
106+
return nil, oop
104107
end
105108

106109
return buildName

test/hover/init.lua

+7
Original file line numberDiff line numberDiff line change
@@ -1664,3 +1664,10 @@ local t: {
16641664
[10]: string = "d",
16651665
}
16661666
]]
1667+
1668+
TEST [[
1669+
function f1.f2.<?f3?>() end
1670+
]]
1671+
[[
1672+
function f1.f2.f3()
1673+
]]

0 commit comments

Comments
 (0)