summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/completion.lua6
-rw-r--r--test/completion/common.lua28
2 files changed, 34 insertions, 0 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 785d3054..4dd55070 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1688,10 +1688,13 @@ end
local function tryluaDocBySource(state, position, source, results)
if source.type == 'doc.extends.name' then
if source.parent.type == 'doc.class' then
+ local used = {}
for _, doc in ipairs(vm.getDocDefines '*') do
if doc.type == 'doc.class.name'
and doc.parent ~= source.parent
+ and not used[doc[1]]
and matchKey(source[1], doc[1]) then
+ used[doc[1]] = true
results[#results+1] = {
label = doc[1],
kind = define.CompletionItemKind.Class,
@@ -1706,10 +1709,13 @@ local function tryluaDocBySource(state, position, source, results)
end
return true
elseif source.type == 'doc.type.name' then
+ local used = {}
for _, doc in ipairs(vm.getDocDefines '*') do
if (doc.type == 'doc.class.name' or doc.type == 'doc.alias.name')
and doc.parent ~= source.parent
+ and not used[doc[1]]
and matchKey(source[1], doc[1]) then
+ used[doc[1]] = true
results[#results+1] = {
label = doc[1],
kind = define.CompletionItemKind.Class,
diff --git a/test/completion/common.lua b/test/completion/common.lua
index 15e2cc2a..3b06d572 100644
--- a/test/completion/common.lua
+++ b/test/completion/common.lua
@@ -2695,3 +2695,31 @@ utf<??>'xxx'
kind = define.CompletionItemKind.Field,
}
}
+
+TEST [[
+---@class AAA
+
+---@class AAA
+
+---@type AAA<??>
+]]
+{
+ [1] = {
+ label = 'AAA',
+ kind = define.CompletionItemKind.Class,
+ }
+}
+
+TEST [[
+---@class AAA
+
+---@class AAA
+
+---@class BBB: AAA<??>
+]]
+{
+ [1] = {
+ label = 'AAA',
+ kind = define.CompletionItemKind.Class,
+ }
+}