summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server/src/core/completion.lua27
-rw-r--r--server/src/vm/vm.lua2
-rw-r--r--server/test/completion/init.lua10
3 files changed, 31 insertions, 8 deletions
diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua
index 54f96295..16b2ad4c 100644
--- a/server/src/core/completion.lua
+++ b/server/src/core/completion.lua
@@ -488,14 +488,25 @@ local function searchSpecial(vm, source, word, callback, pos)
end
end
-- 4. 创建代码片段
- local label = table.concat(chars) .. '+1'
- callback(label, nil, CompletionItemKind.Snippet, {
- textEdit = {
- start = inside.start + 1,
- finish = index.finish,
- newText = ('%s] = '):format(label),
- },
- })
+ if simple:get 'as action' then
+ local label = table.concat(chars) .. '+1'
+ callback(label, nil, CompletionItemKind.Snippet, {
+ textEdit = {
+ start = inside.start + 1,
+ finish = index.finish,
+ newText = ('%s] = '):format(label),
+ },
+ })
+ else
+ local label = table.concat(chars)
+ callback(label, nil, CompletionItemKind.Snippet, {
+ textEdit = {
+ start = inside.start + 1,
+ finish = index.finish,
+ newText = ('%s]'):format(label),
+ },
+ })
+ end
end
local function makeList(source, word)
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 77f428ae..332f4a69 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -974,6 +974,7 @@ function mt:doAction(action)
elseif tp == 'simple' then
-- call
self:getSimple(action)
+ action:set('as action', true)
elseif tp == 'if' then
self:doIf(action)
elseif tp == 'loop' then
@@ -990,6 +991,7 @@ function mt:doAction(action)
self:doLocalFunction(action)
else
self:getExp(action)
+ action:set('as action', true)
end
end
diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua
index 962befa0..5d1ab35a 100644
--- a/server/test/completion/init.lua
+++ b/server/test/completion/init.lua
@@ -577,6 +577,16 @@ fff[#ff@]
}
TEST [[
+local _ = fff.kkk[#@]
+]]
+{
+ {
+ label = 'fff.kkk',
+ kind = CompletionItemKind.Snippet,
+ },
+}
+
+TEST [[
local t = {
a = 1,
}