-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Noticed when writing up #812.
The object a_kinda_long_name
appears 3 times in this completion list:

Notice the three different icons. This means there are 3 different CompletionItems
for this object, each of a distinct kind. This has become possible recently, because we now intentionally create multiple completion items of different kinds (e.g. keyword and snippet) for selected keywords (see #782).
This bug pre-existed #782, it was just hidden by the fact that one of these completion items would get there first and prevent the other two from ever making it into the list. We used to key effectively on label
and now we key on label
and kind
.
I temporarily added some logging and here's a sketch of what's happening:
- First, the search path source nominates
a_kinda_long_name
, with kind 'Struct'. - Then, the document source nominates it again, with kind 'Variable'.
- Finally, the workspace source nominates it a third time, with kind 'Value'.
I imagine the diversity of kinds here is just an accident(?). Copilot thinks "we need a shared helper function that all sources can use to determine the appropriate CompletionItemKind
for R objects" and I have to admit that sounds like a very good idea.
The logging revealed some info on another duplication situation that I already knew about but hadn't studied yet. Just dumping the juicy bits from the log here so I can come back to it. This is all happening within the search path source:
Same label 'pak' but different kinds: existing 'Function' from source search_path vs new 'Module' from source search_path
Same label 'reprex' but different kinds: existing 'Function' from source search_path vs new 'Module' from source search_path
Same label 'zip' but different kinds: existing 'Function' from source search_path vs new 'Module' from source search_path
Same label 'class' but different kinds: existing 'Function' from source search_path vs new 'Module' from source search_path
Same label 'grid' but different kinds: existing 'Function' from source search_path vs new 'Module' from source search_path
Same label 'methods' but different kinds: existing 'Function' from source search_path vs new 'Module' from source search_path
Update after scrutinizing the list just above: these are names that refer to both a package and a function! So it's correct behaviour.