summaryrefslogtreecommitdiff
path: root/script/core/completion/postfix.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-23 22:10:40 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-23 22:10:40 +0800
commit14c0ba0ebbf69426cab28c98409fb04aff89a34d (patch)
treed79bcd1f72e002744b5b6f855dcb7e8b74aa5dfb /script/core/completion/postfix.lua
parent7c176eb6882abbe00b0a1285bbbb4ff2af897b13 (diff)
downloadlua-language-server-14c0ba0ebbf69426cab28c98409fb04aff89a34d.zip
make VSCode happy
Diffstat (limited to 'script/core/completion/postfix.lua')
-rw-r--r--script/core/completion/postfix.lua32
1 files changed, 16 insertions, 16 deletions
diff --git a/script/core/completion/postfix.lua b/script/core/completion/postfix.lua
index 8e21a86d..07c6be8c 100644
--- a/script/core/completion/postfix.lua
+++ b/script/core/completion/postfix.lua
@@ -1,6 +1,7 @@
local guide = require 'parser.guide'
local lookback = require 'core.look-backward'
local matchKey = require 'core.matchkey'
+local subString = require 'core.substring'
local define = require 'proto.define'
local actions = {}
@@ -15,16 +16,9 @@ local function register(key)
end
register 'pcall' {
- function (source, callback)
- callback({
- start = source.start,
- finish = source.start,
- newText = 'pcall(',
- }, {
- start = source.finish,
- finish = source.finish,
- newText = ')',
- })
+ function (state, source, callback)
+ local subber = subString(state)
+ callback(('pcall(%s)'):format(subber(source.start + 1, source.finish)))
end
}
@@ -44,16 +38,22 @@ local function checkPostFix(state, word, wordPosition, position, results)
end)
for _, action in ipairs(actions) do
if matchKey(word, action.key) then
- action.data[1](source, function (...)
+ action.data[1](state, source, function (newText)
results[#results+1] = {
- label = action.key,
- kind = define.CompletionItemKind.Event,
- textEdit = {
- start = wordPosition,
+ label = action.key,
+ kind = define.CompletionItemKind.Event,
+ textEdit = {
+ start = wordPosition + 1,
finish = position,
newText = '',
},
- additionalTextEdits = { ... }
+ additionalTextEdits = {
+ {
+ start = source.start,
+ finish = wordPosition + 1,
+ newText = newText,
+ },
+ },
}
end)
end