-
Notifications
You must be signed in to change notification settings - Fork 167
4.1.0: didOpen fails for .tsx with "Cannot open document" #794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm experiencing a similar issue with ".ts" files in my Emacs environment using version 4.1.0. When I revert back to version 4.0.0, everything works as expected. I haven't tried ".tsx" files. Here's the error message I'm receiving:
|
That's likely because your client (Emacs, etc) sends incorrect language ID for those files. These are the language IDs that should be set for each file type: Previous version of the server was less strict but that likely caused hard to spot issues at a later point. If you look at the |
@rchl Is there a reason the server can't infer this on its own? It does have the file name after all. |
It would in theory but what would the point of the |
In Kate, we have work around a lot of issues that are actually server issues because we don't have much of a choice besides letting it fail and let the user suffer. My point is that rather than breaking perhaps a better idea is to keep a fallback. This matters for some clients like us because we ship once in 4 months. If a server breaks in between releases like this, then an average user is just stuck with a broken server till the next release. Oh and if you are on UbuntuLTS or something like that, then good luck. |
Though neither Kate nor this server are part of Ubuntu so that shouldn't really be relevant. :) I will look into adding a fallback when languageId is wrong. |
Its not a part of Ubuntu, but it is installable on Ubuntu. Thanks for listening :) |
GH Issue typescript-language-server/typescript-language-server#794 setting it to true seems to fix it BUG: 476942 ``` That's likely because your client (Emacs, etc) sends incorrect language ID for those files. These are the language IDs that should be set for each file type: js - javascript ts - typescript jsx - javascriptreact tsx - typescriptreact Previous version of the server was less strict but that likely caused hard to spot issues at a later point. If you look at the textDocument/didOpen request then you'll see what languageId is being passed. ``` BUG: 476942
Hello,
Where is a client author to get this information from? This thread? Or is it some universal information published somewhere.
I assume it's for when files exist in a given language have non-standard extensions so the server can't possibly guess from.
Not really: the client often doesn't know much more about the file's intented language than the server. If Also this leads to hardcoding things on the client side, which at least my client specifically avoids (it works with hundreds of LSP servers and virtually no server-specific code). But I see you've already pushed a commit that fixes this, at least for the time being. |
The official spec lists those relevant to this server at least: https://microsoft.github.io/language-server-protocol/specification#textDocumentItem
Previously the server didn't validate language ID but then the tsserver would receive wrong languageId and not be able to tell the type of the code apart and likely result in some things not working as expected.
The client should know the syntax of the file and thus the language type. Clients should maintain a mapping from syntax/scope to languageId. While it might not apply so much to this server since this one is geared towards normal files, many servers can work on unsaved files that don't have extension and then the only way to tell the language of the file is with the syntax/languageId. So relying on file extension alone is not reliable. |
Thanks, I missed this. |
yeah i use kate and had to downgrade and ignore upgrades for the typescript-language-server package on arch because of this update :/ |
oh nvm i just saw that the fix just requires editing the LSP config, also made a pr to fix lol |
reverting back to 4.0.0 solves the issue.
4,1.0 seems to work for .ts files.
The text was updated successfully, but these errors were encountered: