Skip to content

Commit eeb24f3

Browse files
committed
fix #1288
1 parent 48c53a3 commit eeb24f3

File tree

3 files changed

+27
-15
lines changed

3 files changed

+27
-15
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* `CHG` completion: `completion.callSnippet` no longer generate parameter types
66
* `CHG` hover: show `---@type {x: number, y: number}` as detail instead of `table`
77
* `FIX` [#1278](https://github.com/sumneko/lua-language-server/issues/1278)
8+
* `FIX` [#1288](https://github.com/sumneko/lua-language-server/issues/1288)
89

910
## 3.4.1
1011
`2022-7-5`

script/vm/compiler.lua

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
336336
-- check local field and global field
337337
if not hasFounded[key] and set.bindSources then
338338
for _, src in ipairs(set.bindSources) do
339-
local skipSetLocal
340339
if src.value and src.value.type == 'table' then
341340
searchFieldSwitch('table', suri, src.value, key, ref, function (field)
342341
local fieldKey = guide.getKeyName(field)
@@ -345,25 +344,20 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
345344
and guide.isSet(field) then
346345
hasFounded[fieldKey] = true
347346
pushResult(field, true)
348-
if src.type == 'local' then
349-
skipSetLocal = true
350-
end
351347
end
352348
end
353349
end)
354350
end
355-
if not skipSetLocal then
356-
searchFieldSwitch(src.type, suri, src, key, ref, function (field)
357-
local fieldKey = guide.getKeyName(field)
358-
if fieldKey then
359-
if not searchedFields[fieldKey]
360-
and guide.isSet(field) then
361-
hasFounded[fieldKey] = true
362-
pushResult(field, true)
363-
end
351+
searchFieldSwitch(src.type, suri, src, key, ref, function (field)
352+
local fieldKey = guide.getKeyName(field)
353+
if fieldKey and not hasFounded[fieldKey] then
354+
if not searchedFields[fieldKey]
355+
and guide.isSet(field) then
356+
hasFounded[fieldKey] = true
357+
pushResult(field, true)
364358
end
365-
end)
366-
end
359+
end
360+
end)
367361
end
368362
end
369363
-- look into extends(if field not found)

test/hover/init.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,3 +2074,20 @@ local <?f?>
20742074
[[
20752075
local f: fun():(x: number, y: boolean)
20762076
]]
2077+
2078+
TEST [[
2079+
---@class MyClass
2080+
local MyClass = {
2081+
a = 1
2082+
}
2083+
2084+
function MyClass:Test()
2085+
<?self?>
2086+
end
2087+
]]
2088+
[[
2089+
(self) self: MyClass {
2090+
Test: function,
2091+
a: integer = 1,
2092+
}
2093+
]]

0 commit comments

Comments
 (0)