File tree 2 files changed +53
-2
lines changed
2 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -4572,3 +4572,44 @@ M.create():optional(<??>):self()
4572
4572
kind = define .CompletionItemKind .EnumMember ,
4573
4573
},
4574
4574
}
4575
+
4576
+ TEST [[
4577
+ ---@class Array<T>: { [integer]: T }
4578
+ ---@field length integer
4579
+ local Array
4580
+
4581
+ function Array:push() end
4582
+
4583
+ ---@type Array<string>
4584
+ local a
4585
+ print(a.<??>)
4586
+ ]]
4587
+ {
4588
+ include = true ,
4589
+ {
4590
+ label = ' length' ,
4591
+ kind = define .CompletionItemKind .Field ,
4592
+ },
4593
+ {
4594
+ label = ' push(self)' ,
4595
+ kind = define .CompletionItemKind .Method ,
4596
+ },
4597
+ }
4598
+
4599
+ TEST [[
4600
+ ---@class Array<T>: { [integer]: T }
4601
+ ---@field length integer
4602
+ local Array
4603
+
4604
+ function Array:push() end
4605
+
4606
+ ---@type Array<string>
4607
+ local a
4608
+ print(a:<??>)
4609
+ ]]
4610
+ {
4611
+ {
4612
+ label = ' push()' ,
4613
+ kind = define .CompletionItemKind .Method ,
4614
+ },
4615
+ }
Original file line number Diff line number Diff line change @@ -40,8 +40,18 @@ local function include(a, b)
40
40
return false
41
41
end
42
42
if tp1 == ' table' then
43
- for k in pairs (a ) do
44
- if not eq (a [k ], b [k ]) then
43
+ -- a / b are array of completion results
44
+ -- when checking `include`, the array index order is not important
45
+ -- thus need to check every results in b
46
+ for _ , v1 in ipairs (a ) do
47
+ local ok = false
48
+ for _ , v2 in ipairs (b ) do
49
+ if eq (v1 , v2 ) then
50
+ ok = true
51
+ break
52
+ end
53
+ end
54
+ if not ok then
45
55
return false
46
56
end
47
57
end
You can’t perform that action at this time.
0 commit comments