summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/vm/field.lua10
-rw-r--r--test/completion/common.lua18
2 files changed, 27 insertions, 1 deletions
diff --git a/script/vm/field.lua b/script/vm/field.lua
index b92c3a7b..db53509b 100644
--- a/script/vm/field.lua
+++ b/script/vm/field.lua
@@ -24,11 +24,19 @@ local function searchByLocalID(source, pushResult)
end
end
-local function searchByNode(source, pushResult)
+local function searchByNode(source, pushResult, mark)
+ mark = mark or {}
+ if mark[source] then
+ return
+ end
+ mark[source] = true
local uri = guide.getUri(source)
vm.compileByParentNode(source, nil, true, function (field)
searchByNodeSwitch(field.type, uri, field, pushResult)
end)
+ vm.compileByNodeChain(source, function (src)
+ searchByNode(src, pushResult, mark)
+ end)
end
---@param source parser.object
diff --git a/test/completion/common.lua b/test/completion/common.lua
index 8fa8c26a..9f5e5f6f 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -3777,3 +3777,21 @@ acceptOptions({
(function (results)
assert(#results == 2)
end)
+
+TEST [[
+local t1 = {}
+
+t1.A = {}
+t1.A.B = {}
+t1.A.B.C = 1
+
+local t2 = t1
+
+print(t2.A.<??>)
+]]
+{
+ {
+ label = 'B',
+ kind = define.CompletionItemKind.Field,
+ },
+}