Skip to content

Exclude top-level imports from document symbols - #64160

Open
Jake Bailey (jakebailey) with Copilot wants to merge 4 commits into
mainfrom
copilot/should-native-lsp-include-imports
Open

Jake Bailey (jakebailey) with Copilot wants to merge 4 commits into
mainfrom
copilot/should-native-lsp-include-imports

Conversation

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

The native LSP reported top-level imports through textDocument/documentSymbol, unlike the established VS Code Outline behavior.

  • Document symbols
    • Skip top-level import and import-equals declarations.
    • Preserve ordinary declarations and nested symbols.
import { value } from "./values";
const local = 1;

The response includes local, but not value.

Copilot AI and others added 2 commits September 3, 2026 22:52
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
@@ -1,23 +1,4 @@
// === Document Symbols ===
// === /navigationBarItemsImports.ts ===

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, I forgot that the outline also powers the navigation bar. Maybe nobody's navigating within an import?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I just checked, and VSCode LSP doesn't allow navigation inside imports either.
image

Copilot AI changed the title [WIP] Fix TypeScript LSP documentSymbol response for top-level imports Exclude top-level imports from document symbols Sep 3, 2026
@jakebailey
Jake Bailey (jakebailey) marked this pull request as ready for review September 21, 2026 19:07
Copilot AI balanced review requested due to automatic review settings September 21, 2026 19:07
@jakebailey

Copy link
Copy Markdown
Member

Marking as ready for review, but we need to make sure this doesn't regress VS. Joaquin Jares (@joj) navya9singh for awareness.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The early return unintentionally suppresses JSDoc typedef and callback symbols attached to imports.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Excludes top-level imports from native LSP document symbols while retaining regular declarations.

Changes:

  • Filters import and import-equals declarations.
  • Adds and updates fourslash coverage and baselines.
File Description
tsc/​internal/​ls/​symbols.go Filters top-level imports.
tsc/​internal/​fourslash/​tests/​documentSymbolTopLevelImports_test.go Adds regression coverage.
tsc/​testdata/​baselines/​reference/​fourslash/​documentSymbols/​documentSymbolTopLevelImports.baseline Records mixed import/declaration output.
tsc/​testdata/​baselines/​reference/​fourslash/​documentSymbols/​navigationBarItemsImports.baseline Removes imported symbols.
tsc/​testdata/​baselines/​reference/​fourslash/​documentSymbols/​navigationBarItemsExports.baseline Removes exported import-equals symbol.
tsc/​testdata/​baselines/​reference/​fourslash/​documentSymbols/​navigationBarImports.baseline Removes imported symbols.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread tsc/internal/ls/symbols.go Outdated
if ctx.Err() != nil {
return true
}
if node.Parent.Kind == ast.KindSourceFile && ast.IsImportOrImportEqualsDeclaration(node) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copilot Consider and address.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in b163116. JSDoc typedef and callback symbols are emitted before filtering the top-level import, with regression coverage for both.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should the native TypeScript LSP include top-level imports in its textDocument/documentSymbol response?

4 participants