summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-06-13 21:00:02 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-06-13 21:00:02 +0800
commit484f993c6a1026b7eb04d48ff4aee00e2dcafd54 (patch)
tree2ca3a0da2c4bc39a0c58a2983bb033a1fbefc7ec /script/vm
parent2b5257d3d097c2726e5098a43c333aa20a461c2e (diff)
downloadlua-language-server-484f993c6a1026b7eb04d48ff4aee00e2dcafd54.zip
completion for quoted fields
fix #2088
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/infer.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index 94fdfd88..3bc0b3f7 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -565,11 +565,12 @@ function vm.viewKey(source, uri)
return vm.viewKey(source.types[1], uri)
else
local key = vm.getInfer(source):view(uri)
- return '[' .. key .. ']'
+ return '[' .. key .. ']', key
end
end
if source.type == 'tableindex'
- or source.type == 'setindex' then
+ or source.type == 'setindex'
+ or source.type == 'getindex' then
local index = source.index
local name = vm.getInfer(index):viewLiterals()
if not name then
@@ -587,7 +588,11 @@ function vm.viewKey(source, uri)
return vm.viewKey(source.name, uri)
end
if source.type == 'doc.type.name' then
- return '[' .. source[1] .. ']'
+ return '[' .. source[1] .. ']', source[1]
+ end
+ if source.type == 'doc.type.string' then
+ local name = util.viewString(source[1], source[2])
+ return ('[%s]'):format(name), name
end
local key = vm.getKeyName(source)
if key == nil then