Skip to content

Fix double-output of document symbols that are scopes#200

Open
JonatanWaern wants to merge 1 commit intomainfrom
fix-document-symbols
Open

Fix double-output of document symbols that are scopes#200
JonatanWaern wants to merge 1 commit intomainfrom
fix-document-symbols

Conversation

@JonatanWaern
Copy link
Contributor

Signed-off-by: Jonatan Waern jonatan.waern@intel.com

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::Simple entries when they correspond to scope-like kinds that are also emitted as SubSymbol::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.

Comment on lines 376 to 379
children: Some(context.subsymbols.iter()
.filter(|subsymbol|should_output_symbol_for_subsymbol(subsymbol))
.map(subsymbol_to_document_symbol)
.collect()),
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Signed-off-by: Jonatan Waern <jonatan.waern@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants