diff options
-rw-r--r-- | script/provider/provider.lua | 3 | ||||
-rw-r--r-- | test/tclient/init.lua | 1 | ||||
-rw-r--r-- | test/tclient/tests/resolve-completion.lua | 58 |
3 files changed, 61 insertions, 1 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index b8b101ed..ea3f2442 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -521,7 +521,8 @@ m.register 'textDocument/completion' { local count, max = workspace.getLoadingProcess(uri) return { { - label = lang.script('HOVER_WS_LOADING', count, max),textEdit = { + label = lang.script('HOVER_WS_LOADING', count, max), + textEdit = { range = { start = params.position, ['end'] = params.position, diff --git a/test/tclient/init.lua b/test/tclient/init.lua index 7c8d70ef..9e1db8d4 100644 --- a/test/tclient/init.lua +++ b/test/tclient/init.lua @@ -4,3 +4,4 @@ require 'tclient.tests.multi-workspace' require 'tclient.tests.folders-with-single-file' require 'tclient.tests.load-library' require 'tclient.tests.files-associations' +require 'tclient.tests.resolve-completion' 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) |