Fix double-output of document symbols that are scopes#200
Fix double-output of document symbols that are scopes#200JonatanWaern wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes duplicate reporting in the LSP document symbols output when a symbol is both a “flat” symbol and a scope/context in the internal model.
Changes:
- Added a filter to drop certain
SubSymbol::Simpleentries when they correspond to scope-like kinds that are also emitted asSubSymbol::Context. - Applied the filter when constructing
DocumentSymbol.children. - Documented the fix in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/actions/requests.rs |
Adds a de-duplication filter for scope-like symbols when building nested document symbols. |
CHANGELOG.md |
Adds a release note about fixing double-reporting in document symbol responses. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| children: Some(context.subsymbols.iter() | ||
| .filter(|subsymbol|should_output_symbol_for_subsymbol(subsymbol)) | ||
| .map(subsymbol_to_document_symbol) | ||
| .collect()), |
There was a problem hiding this comment.
The de-duplication filter is only applied when building children inside context_to_document_symbol. However, DocumentSymbolRequest::handle still folds out the toplevel context by mapping context.subsymbols directly, so scope-like symbols (templates/objects/methods) that are direct children of the file root can still be double-reported (they exist as both SubSymbol::Simple and SubSymbol::Context from Scope::to_context). Consider applying the same filter when producing the top-level symbols list as well (or moving the filtering into the common conversion path).
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
4706942 to
c48402c
Compare
Signed-off-by: Jonatan Waern jonatan.waern@intel.com