summaryrefslogtreecommitdiff
path: root/script/core/completion
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-23 22:29:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-23 22:29:32 +0800
commit3d2dfa3775302784b632a7e147d77ff92dfd7346 (patch)
treee2071774d65b971c196916a963213c5f65e6ce50 /script/core/completion
parent14c0ba0ebbf69426cab28c98409fb04aff89a34d (diff)
downloadlua-language-server-3d2dfa3775302784b632a7e147d77ff92dfd7346.zip
make VSCode happy
Diffstat (limited to 'script/core/completion')
-rw-r--r--script/core/completion/postfix.lua21
1 files changed, 18 insertions, 3 deletions
diff --git a/script/core/completion/postfix.lua b/script/core/completion/postfix.lua
index 07c6be8c..16bada87 100644
--- a/script/core/completion/postfix.lua
+++ b/script/core/completion/postfix.lua
@@ -18,7 +18,22 @@ end
register 'pcall' {
function (state, source, callback)
local subber = subString(state)
- callback(('pcall(%s)'):format(subber(source.start + 1, source.finish)))
+ if source.type == 'call' then
+ if source.args and #source.args > 0 then
+ callback(string.format('pcall(%s, %s)'
+ , subber(source.node.start + 1, source.node.finish)
+ , subber(source.args[1].start + 1, source.args[#source.args].finish)
+ ))
+ else
+ callback(string.format('pcall(%s)'
+ , subber(source.node.start + 1, source.node.finish)
+ ))
+ end
+ else
+ callback(string.format('pcall(%s)'
+ , subber(source.start + 1, source.finish)
+ ))
+ end
end
}
@@ -45,13 +60,13 @@ local function checkPostFix(state, word, wordPosition, position, results)
textEdit = {
start = wordPosition + 1,
finish = position,
- newText = '',
+ newText = newText,
},
additionalTextEdits = {
{
start = source.start,
finish = wordPosition + 1,
- newText = newText,
+ newText = '',
},
},
}