Fix duplicated completion candidates to solve #6#8
Conversation
|
Well, I don't think you can use ordered-dedupe here... because the result of find-available-references is not ordered. |
|
Thank you for the valuable feedback. You're absolutely right that we need to focus on the root cause rather than applying temporary patches. After analyzing the Root Cause AnalysisThe core problem could be in For debug usage, I restructure the first case of the function Based on the log, I assume the following reasons: 1. Exponential Reference Multiplication
Evidence from Debug Log: Results growing from ~1,575 → 2,265 → 10,412 references per call. Also, this could be the reason why the server repeatedly cancels/timeouts some requests of 2. Ineffective Deduplication Strategy
Evidence from Debug Log: The analysis may not be correct and needs to be explored deeper, but this is what I can find out so far, and no ideal/effective fix yet. |
|
You should minimize your |
Fix: fix duplicated reference in one index-node
|
The original duplications appear both in Logs of showing Logs of showing The problem should be resolved by ending with The duplications both in |
Description
This PR fixes an issue where the language server would return duplicate completion items for the same identifier. The problem was particularly noticeable with identifiers like
broken-functionappearing multiple times in completion suggestions.Root Cause
The
find-available-references-forfunction was collecting all references to an identifier without deduplication, resulting in multiple identical completion items when an identifier was defined in several places or imported from multiple sources.Solution
Applied
ordered-dedupeto filter identifier references before converting them to completion items:eq?equality predicate onidentifier-reference-identifierto identify duplicatesImplementation
[whole-list (if (null? target-index-node) '() (ordered-dedupe (if (equal? "" prefix) (find-available-references-for document target-index-node) (filter (lambda (candidate-reference) (string-prefix? prefix (symbol->string (identifier-reference-identifier candidate-reference)))) (find-available-references-for document target-index-node))) (lambda (a b) (eq? (identifier-reference-identifier a) (identifier-reference-identifier b)))))]Benefits
Related Issues
Fixes #6