summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/core/completion.lua11
-rw-r--r--server/src/core/vm.lua14
2 files changed, 13 insertions, 12 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index bff1bd33..685aa8d3 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -511,14 +511,15 @@ end
local function searchSpecial(vm, pos, callback)
-- 尝试 #
- local result, source = findResult(vm, pos, 2)
- if source and source.indexSource and result.source.op == '#'
+ local var = findResult(vm, pos)
+ local _, source = findResult(vm, pos, 2)
+ if source and source.indexName and source[1].op == '#'
then
- local label = source.indexSource.indexName .. '+1'
+ local label = source.indexName .. '+1'
callback(label, CompletionItemKind.Snippet, {
textEdit = {
- start = source.start + 1,
- finish = source.indexSource.finish,
+ start = var.source.start,
+ finish = source.finish,
newText = ('%s] = '):format(label),
}
})
diff --git a/server/src/core/vm.lua b/server/src/core/vm.lua
index b7ae4055..cda8422e 100644
--- a/server/src/core/vm.lua
+++ b/server/src/core/vm.lua
@@ -939,17 +939,18 @@ function mt:getSimple(simple, mode)
parentName = parentName .. '(...)'
elseif tp == 'index' then
local child = obj[1]
- child.indexSource = obj
obj.indexName = parentName
local index = self:getIndex(child)
if mode == 'value' or i < #simple then
- local indexField = self:getField(value, index, child) or self:createField(value, index, child)
- value = self:getValue(indexField)
+ field = self:getField(value, index, obj) or self:createField(value, index, obj)
+ value = self:getValue(field)
self:addInfo(field, 'get', obj)
else
- local indexField = self:createField(value, index, child)
- value = self:getValue(indexField)
+ field = self:createField(value, index, obj)
+ value = self:getValue(field)
end
+ field.parentValue = value
+ field.parent = lastField
if obj[1].type == 'string' then
parentName = ('%s[%q]'):format(parentName, index)
elseif obj[1].type == 'number' or obj[1].type == 'boolean' then
@@ -960,14 +961,13 @@ function mt:getSimple(simple, mode)
elseif tp == 'name' then
if mode == 'value' or i < #simple then
field = self:getField(value, obj[1], obj) or self:createField(value, obj[1], obj)
- field.parentValue = value
value = self:getValue(field)
self:addInfo(field, 'get', obj)
else
field = self:createField(value, obj[1], obj)
- field.parentValue = value
value = self:getValue(field)
end
+ field.parentValue = value
field.parent = lastField
lastField = field
obj.object = object