summaryrefslogtreecommitdiff
path: root/test/tclient/tests/resolve-completion.lua
diff options
context:
space:
mode:
authorAlexCai2019 <89138532+AlexCai2019@users.noreply.github.com>2022-05-08 01:43:28 +0800
committerGitHub <noreply@github.com>2022-05-08 01:43:28 +0800
commit0fd83c4ca9f82a02becab6c304a8a7de75098507 (patch)
treebe9790d9d4823fe728c5b36e94093fe5f42b7725 /test/tclient/tests/resolve-completion.lua
parent89203efad8c9b5513e05ca4d5696107924865b10 (diff)
parent67b4c574849d1667e0ecb39c51aeed8e30b43056 (diff)
downloadlua-language-server-0fd83c4ca9f82a02becab6c304a8a7de75098507.zip
Merge branch 'sumneko:master' into master
Diffstat (limited to 'test/tclient/tests/resolve-completion.lua')
-rw-r--r--test/tclient/tests/resolve-completion.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/test/tclient/tests/resolve-completion.lua b/test/tclient/tests/resolve-completion.lua
new file mode 100644
index 00000000..a7cf2c2f
--- /dev/null
+++ b/test/tclient/tests/resolve-completion.lua
@@ -0,0 +1,58 @@
+local lclient = require 'lclient'
+local ws = require 'workspace'
+local util = require 'utility'
+
+---@async
+lclient():start(function (client)
+ client:registerFakers()
+ client:initialize()
+
+ client:notify('textDocument/didOpen', {
+ textDocument = {
+ uri = 'file://test.lua',
+ languageId = 'lua',
+ version = 0,
+ text = [[
+---@type integer
+local xxxx
+
+x
+]]
+ }
+ })
+
+ ws.awaitReady()
+
+ local completions = client:awaitRequest('textDocument/completion', {
+ textDocument = { uri = 'file://test.lua' },
+ position = { line = 3, character = 1 },
+ })
+
+ client:awaitRequest('textDocument/didChange',
+ {
+ textDocument = { uri = 'file://test.lua' },
+ contentChanges = {
+ {
+ range = {
+ start = { line = 3, character = 1 },
+ ['end'] = { line = 3, character = 1 },
+ },
+ text = 'x'
+ }
+ }
+ })
+
+ local targetItem
+ for _, item in ipairs(completions.items) do
+ if item.label == 'xxxx' then
+ targetItem = item
+ break
+ end
+ end
+
+ assert(targetItem ~= nil)
+
+ local newItem = client:awaitRequest('completionItem/resolve', targetItem)
+
+ assert(newItem.detail == 'integer')
+end)