Repository navigation
Return null from the remaining content-mapper fallbacks - #65532
Closed
Josué Barros (joshbarros) wants to merge 2 commits into
Closed
Josué Barros (joshbarros) wants to merge 2 commits into
Josué Barros (joshbarros) wants to merge 2 commits into
Conversation
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
Contributor
There was a problem hiding this comment.
🟡 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
nullfor ten additional requests, including formatting, inlay hints, code lenses, and call hierarchy. - Extends the lifecycle test to exercise these requests after unregistration.
- Leaves
completionItem/resolvehandling 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.contentMapperFallbackResponseonly 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/resolvestill 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/lspand the repo'sgofmt: clean.Drafted with assistance from an AI assistant. I reviewed the diff and ran the tests above.