Skip to content

Return null from the remaining content-mapper fallbacks - #65532

Closed
Josué Barros (joshbarros) wants to merge 2 commits into
microsoft:mainfrom
joshbarros:fix/65525-content-mapper-fallbacks
Closed

Josué Barros (joshbarros) wants to merge 2 commits into
microsoft:mainfrom
joshbarros:fix/65525-content-mapper-fallbacks

Conversation

@joshbarros

Copy link
Copy Markdown

Fixes #65525

When a content mapper is unregistered but the client still has the file open, some requests return a null result and others fail with no project for unknown script kind. contentMapperFallbackResponse only covered hover, signature help, definition, type definition, implementation, references, document highlight, completion and rename.

This adds the rest of the affected requests: inlay hint, code lens, formatting, range formatting, on-type formatting, linked editing range, prepare call hierarchy, prepare rename, and incoming/outgoing call hierarchy. completionItem/resolve still returns a different error and needs its own handling, so it is not included here.

The content-mapper lifecycle test now sends each of these requests after unregistration and asserts a null result instead of an error.

Validation:

  • go test ./tsc/internal/lsp -run TestSetContentMapperContributionsBeforeDidOpen -count=1: fails on the first uncovered request without the change, passes with it.
  • go test ./tsc/internal/lsp -count=1: pass.
  • go vet ./tsc/internal/lsp and the repo's gofmt: clean.

Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.

When a content mapper is unregistered but the client still has the file open, some requests return a null result and others fail with 'no project for unknown script kind'. contentMapperFallbackResponse only covered hover, signature help, definition, type definition, implementation, references, document highlight, completion and rename.

Cover inlay hint, code lens, formatting, range formatting, on-type formatting, linked editing range, prepare call hierarchy, prepare rename, and incoming/outgoing call hierarchy. Extend the content-mapper lifecycle test to send each one after unregistration and assert a null result instead of an error.

Fixes microsoft#65525
Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:49
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 16, 2026
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 16, 2026

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.

🟡 Changes recommended

The test helper does not assert that results are JSON null, allowing non-null responses such as [] to pass without enforcing the fallback contract across all ten requests.

1 open issue
What changed in this PR

Expands language-server fallbacks for files left open after content-mapper unregistration, addressing errors reported in #65525.

Changes:

  • Returns null for ten additional requests, including formatting, inlay hints, code lenses, and call hierarchy.
  • Extends the lifecycle test to exercise these requests after unregistration.
  • Leaves completionItem/resolve handling outside this change.
File Description
tsc/​internal/​lsp/​server.go Adds ten request methods to the null-fallback response list.
tsc/​internal/​lsp/​server_contentmapper_test.go Adds post-unregistration requests and checks for successful responses.

Review effort: Balanced

The shared test helper only checked for a successful decode, so a non-null result such as an empty array would still pass. Assert the raw JSON-RPC result is null for every fallback request.
@github-project-automation github-project-automation Bot moved this from Not started to Done in PR Backlog Nov 16, 2026
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

Status: Done

Development

Successfully merging this pull request may close these issues.

Missing content-mapper fallbacks cause internal LSP errors

3 participants