Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- The DLS will now correctly report missing template names in 'in each' constructs
- Fixed error where the DLS would fail to match references from within in a template
to symbols defined in parents of objects instantiating the template
- Fixed an issue where the DLS document and workspace symbol request would
double-report symbols that contain other symbols (methods, templates, objects)

## 0.9.17
- Fixed linter wrongly throwing an error on space after `defined` keyword
Expand Down
21 changes: 19 additions & 2 deletions src/actions/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,18 @@ fn simplesymbol_to_workspace_symbol(parent_name: &str,
}
}

// Filter out the flat simplesymbols that will also be output as
// contexts
fn should_output_symbol_for_subsymbol(sym: &SubSymbol) -> bool {
match sym {
SubSymbol::Context(_) => true,
SubSymbol::Simple(simple) => !matches!(simple.kind(),
DMLSymbolKind::CompObject(_)
| DMLSymbolKind::Template
| DMLSymbolKind::Method),
}
}

fn context_to_document_symbol(context: &SymbolContext) -> DocumentSymbol {
// Note: This is probably slightly inefficient for simple contexts,
// but is unlikely to be a large problem
Expand All @@ -230,6 +242,7 @@ fn context_to_document_symbol(context: &SymbolContext) -> DocumentSymbol {
range: ls_util::dls_to_range(span.range),
selection_range: ls_util::dls_to_range(loc.range),
children: Some(context.subsymbols.iter()
.filter(|subsymbol|should_output_symbol_for_subsymbol(subsymbol))
.map(subsymbol_to_document_symbol)
.collect()),
Comment on lines 244 to 247
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.
}
Expand Down Expand Up @@ -259,6 +272,9 @@ fn context_to_workspace_symbols_aux(context: &SymbolContext,
});

for child in &context.subsymbols {
if !should_output_symbol_for_subsymbol(child) {
continue;
}
match child {
SubSymbol::Context(con) => context_to_workspace_symbols_aux(
con, Some(&full_name), symbols),
Expand Down Expand Up @@ -333,8 +349,9 @@ impl RequestAction for DocumentSymbolRequest {
.map(|isolated|{
let context = isolated.toplevel.to_context();
// Fold out the toplevel context
let symbols = context.subsymbols.iter().map(
subsymbol_to_document_symbol).collect();
let symbols = context.subsymbols.iter()
.filter(|s|should_output_symbol_for_subsymbol(s))
.map(subsymbol_to_document_symbol).collect();
Some(DocumentSymbolResponse::Nested(symbols))
})
.or(Self::fallback_response())
Expand Down