Duplicated completion items
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 337
- Forks
- 32
- Avg merge
- 8d 17h
- Merged PRs (30d)
- 11
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the search path, document, and workspace completion sources that produce CompletionItems, using the duplicate-label logs as the reproduction. Done means repeated labels such as a_kinda_long_name no longer appear as accidental duplicates while legitimate package/function pairs such as pak remain distinct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100