Skip to content

Commit 2103f3f

Browse files
authored
LSP fix duplicate workspace symbols (#4084)
1 parent 0ef19ba commit 2103f3f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

private/buf/buflsp/server.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,22 +533,26 @@ func (s *server) Symbols(
533533
query := strings.ToLower(params.Query)
534534

535535
var results []protocol.SymbolInformation
536-
for uri, file := range s.fileManager.uriToFile.Range {
536+
for _, file := range s.fileManager.uriToFile.Range {
537537
if file.ir.IsZero() {
538-
s.lsp.logger.DebugContext(ctx, fmt.Sprintf("workspace symbol: skipping file without IR: %s", uri))
539538
continue
540539
}
541-
542540
// Search through all symbols in this file.
543541
for _, sym := range file.symbols {
544542
if sym.ir.IsZero() {
545543
continue
546544
}
545+
// Only include definitions: static and referenceable symbols.
546+
// Skip references, imports, builtins, and tags
547+
_, isStatic := sym.kind.(*static)
548+
_, isReferenceable := sym.kind.(*referenceable)
549+
if !isStatic && !isReferenceable {
550+
continue
551+
}
547552
symbolInfo := sym.GetSymbolInformation()
548553
if symbolInfo.Name == "" {
549554
continue // Symbol information not supported for this symbol.
550555
}
551-
552556
// Filter by query (case-insensitive substring match)
553557
if query != "" && !strings.Contains(strings.ToLower(symbolInfo.Name), query) {
554558
continue
@@ -559,7 +563,6 @@ func (s *server) Symbols(
559563
}
560564
}
561565
}
562-
563566
slices.SortFunc(results, func(a, b protocol.SymbolInformation) int {
564567
if a.Name != b.Name {
565568
return strings.Compare(a.Name, b.Name)

0 commit comments

Comments
 (0)