Skip to content

Commit 096ff4e

Browse files
committed
create test
1 parent a379960 commit 096ff4e

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

script/provider/provider.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,8 @@ m.register 'textDocument/completion' {
521521
local count, max = workspace.getLoadingProcess(uri)
522522
return {
523523
{
524-
label = lang.script('HOVER_WS_LOADING', count, max),textEdit = {
524+
label = lang.script('HOVER_WS_LOADING', count, max),
525+
textEdit = {
525526
range = {
526527
start = params.position,
527528
['end'] = params.position,

test/tclient/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ require 'tclient.tests.multi-workspace'
44
require 'tclient.tests.folders-with-single-file'
55
require 'tclient.tests.load-library'
66
require 'tclient.tests.files-associations'
7+
require 'tclient.tests.resolve-completion'
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
local lclient = require 'lclient'
2+
local ws = require 'workspace'
3+
local util = require 'utility'
4+
5+
---@async
6+
lclient():start(function (client)
7+
client:registerFakers()
8+
client:initialize()
9+
10+
client:notify('textDocument/didOpen', {
11+
textDocument = {
12+
uri = 'file://test.lua',
13+
languageId = 'lua',
14+
version = 0,
15+
text = [[
16+
---@type integer
17+
local xxxx
18+
19+
x
20+
]]
21+
}
22+
})
23+
24+
ws.awaitReady()
25+
26+
local completions = client:awaitRequest('textDocument/completion', {
27+
textDocument = { uri = 'file://test.lua' },
28+
position = { line = 3, character = 1 },
29+
})
30+
31+
client:awaitRequest('textDocument/didChange',
32+
{
33+
textDocument = { uri = 'file://test.lua' },
34+
contentChanges = {
35+
{
36+
range = {
37+
start = { line = 3, character = 1 },
38+
['end'] = { line = 3, character = 1 },
39+
},
40+
text = 'x'
41+
}
42+
}
43+
})
44+
45+
local targetItem
46+
for _, item in ipairs(completions.items) do
47+
if item.label == 'xxxx' then
48+
targetItem = item
49+
break
50+
end
51+
end
52+
53+
assert(targetItem ~= nil)
54+
55+
local newItem = client:awaitRequest('completionItem/resolve', targetItem)
56+
57+
assert(newItem.detail == 'integer')
58+
end)

0 commit comments

Comments
 (0)