Skip to content

Commit e36ca2b

Browse files
committed
fix #1051
1 parent 8a2cab3 commit e36ca2b

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# changelog
22

3+
## 3.1.1
4+
* `FIX` [#1051](https://github.com/sumneko/lua-language-server/issues/1051)
5+
36
## 3.1.0
47
`2022-4-17`
58
* `NEW` support find definition in method

script/vm/field.lua

+11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
local vm = require 'vm.vm'
33
local util = require 'utility'
44
local guide = require 'parser.guide'
5+
local localID = require 'vm.local-id'
56

67
local searchByNodeSwitch = util.switch()
78
: case 'global'
@@ -15,6 +16,15 @@ local searchByNodeSwitch = util.switch()
1516
pushResult(source)
1617
end)
1718

19+
local function searchByLocalID(source, pushResult)
20+
local fields = localID.getFields(source)
21+
if fields then
22+
for _, field in ipairs(fields) do
23+
pushResult(field)
24+
end
25+
end
26+
end
27+
1828
local function searchByNode(source, pushResult)
1929
local uri = guide.getUri(source)
2030
vm.compileByParentNode(source, nil, true, function (field)
@@ -35,6 +45,7 @@ function vm.getFields(source)
3545
end
3646
end
3747

48+
searchByLocalID(source, pushResult)
3849
searchByNode(source, pushResult)
3950

4051
return results

test/completion/common.lua

+13
Original file line numberDiff line numberDiff line change
@@ -3311,3 +3311,16 @@ TEST [[
33113311
end
33123312
assert(count == 1)
33133313
end)
3314+
3315+
TEST [[
3316+
local x
3317+
x.y.z = xxx
3318+
3319+
x.y.<??>
3320+
]]
3321+
{
3322+
{
3323+
label = 'z',
3324+
kind = define.CompletionItemKind.Field,
3325+
}
3326+
}

0 commit comments

Comments
 (0)