Implement "Request Forwarding to tsserver"#207
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: d00ba1c The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
6f5fc97 to
706f9fb
Compare
typescript.tsserverRequest
Owner
Author
|
TODO:
|
Owner
Author
|
A long-standing problem has been resolved! 🎉 |
This was referenced Jun 23, 2025
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.
close: #121
close: #206
Background
The tsserver loaded with ts-plugin will respond to LSP requests for
.css. Meanwhile, the standard CSS Language Server also responds to LSP requests for.css.Which Language Server processes a request depends on the request type. "completions" and "references" requests are sent to both Language Servers, and the merged responses are used. "rename" requests are sent only to the highest-priority Language Server, and its response is used.
The priority of Language Servers depends on the editor and its user settings. Zed allows users to control this with the
languages.CSS.language_serversoption. In VS Code, the standard CSS Language Server has the highest priority and cannot be controlled by the user.In VS Code, "rename" and "documentLink" requests are sent only to the standard CSS Language Server, not to tsserver. As a result, there are some bugs in VS Code.
.cssdoes not work in VS Code #121Proposed changes
Use the VS Code Extension API to pseudo-change the priority of the Language Server used for "rename" and "documentLink" requests. I call this approach "Request Forwarding to tsserver".
First, register the provider that receives ‘rename’ and “documentLink” requests in the VS Code Extension. Use the following API to do this.
Next, send "rename" and "documentLink" requests from the provider to tsserver. Use
vscode.commands.executeCommand('typescript.tsserverRequest', '_xxx', request)andinfo.session.addProtocolHandler('_xxx', (request) => {...})to do this.Finally, convert the response from tsserver into the format expected by the provider. This ensures that "rename" and "documentLink" requests are sent to tsserver.
The following code demonstrates the concept:
Video
2025-06-23.0.59.05.mov
2025-06-23.1.00.37.mov