Skip to content

Commit 88b1559

Browse files
committed
fix repeated docname
1 parent 06d0640 commit 88b1559

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

script/core/completion/completion.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,24 +1671,32 @@ end
16711671

16721672
local function tryluaDocByErr(state, position, err, docState, results)
16731673
if err.type == 'LUADOC_MISS_CLASS_EXTENDS_NAME' then
1674+
local used = {}
16741675
for _, doc in ipairs(vm.getDocSets(state.uri)) do
16751676
if doc.type == 'doc.class'
1677+
and not used[doc.class[1]]
16761678
and doc.class[1] ~= docState.class[1] then
1679+
used[doc.class[1]] = true
16771680
results[#results+1] = {
16781681
label = doc.class[1],
16791682
kind = define.CompletionItemKind.Class,
16801683
}
16811684
end
16821685
end
16831686
elseif err.type == 'LUADOC_MISS_TYPE_NAME' then
1687+
local used = {}
16841688
for _, doc in ipairs(vm.getDocSets(state.uri)) do
1685-
if doc.type == 'doc.class' then
1689+
if doc.type == 'doc.class'
1690+
and not used[doc.class[1]] then
1691+
used[doc.class[1]] = true
16861692
results[#results+1] = {
16871693
label = doc.class[1],
16881694
kind = define.CompletionItemKind.Class,
16891695
}
16901696
end
1691-
if doc.type == 'doc.alias' then
1697+
if doc.type == 'doc.alias'
1698+
and not used[doc.alias[1]] then
1699+
used[doc.alias[1]] = true
16921700
results[#results+1] = {
16931701
label = doc.alias[1],
16941702
kind = define.CompletionItemKind.Class,

test/completion/common.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3292,3 +3292,22 @@ local t = x[<??>]
32923292
assert(res.label ~= 'do')
32933293
end
32943294
end)
3295+
3296+
TEST [[
3297+
---@class ZZZZZ.XXXX
3298+
---@class ZZZZZ.XXXX
3299+
---@class ZZZZZ.XXXX
3300+
---@class ZZZZZ.XXXX
3301+
---@class ZZZZZ.XXXX
3302+
3303+
---@type <??>
3304+
]]
3305+
(function (results)
3306+
local count = 0
3307+
for _, res in ipairs(results) do
3308+
if res.label == 'ZZZZZ.XXXX' then
3309+
count = count + 1
3310+
end
3311+
end
3312+
assert(count == 1)
3313+
end)

0 commit comments

Comments
 (0)