LSP - ts errors on newly opened files don't show until switching file
Closed this issue · 5 comments
That's really of odd - I can't reproduce the issue (only tried in in insiders VS Code though). Can you set your log level to "trace" in VS Code and see whether textDocument/diagnostic is being requested when first opening the file?
This is the order of LSP messages around a file I just reproduced this on:
I opened the file:
[Trace - 7:08:41 AM] Sending notification 'textDocument/didOpen'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Projects/x/y/file.play.ts",
"languageId": "typescript",
"version": 1,
"text"
I seem to get intellisense but see no errors:
[Trace - 7:08:41 AM] Sending request 'textDocument/documentSymbol - (15)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Projects/x/y/file.play.ts"
[Trace - 7:08:43 AM] Sending request 'textDocument/hover - (21)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Projects/x/y/file.play.ts"
},
"position": {
"line": 16,
"character": 69
}
}
[Trace - 7:08:50 AM] Sending request 'textDocument/hover - (22)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Projects/x/y/file.play.ts"
},
"position": {
"line": 3,
"character": 33
}
}
[Trace - 7:08:50 AM] Received response 'textDocument/hover - (22)' in 4ms.
Result: {
"contents": {
"kind": "markdown",
"value": "```tsx\nvar utils: Utils\n```\n"
}
}
I click to open the tsgo logs, the window loses focus, I get the diagnostic request:
[Trace - 7:09:13 AM] Sending request 'textDocument/diagnostic - (29)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Projects/x/y/file.play.ts"
}
}
[Trace - 7:09:13 AM] Received response 'textDocument/diagnostic - (29)' in 8ms.
Result: {
"kind": "full",
and I get errors. So indeed the diagnostic request isn't coming until the text editor loses focus.
I did upgrade to windows 11 and re-setup vscode but I have pretty-much the same setup I had before, but its possible its a plugin.
The bug does not effect eslint. I will disable plugins and retry.
Also happens with all other plugins disabled.
To be clear:
- close document that has errors
- restart tsgo
- wait 10 seconds
- open document with errors
- wait as long as you like - no errors
- switch to a different document, or open tsgo logs - diagnostic comes and errors appear.
if diagnostic is always guaranteed to be sent on open then it could be a vscode bug. I will try the preview version of vscode.
this bug does not occur using insiders preview vscode - even with the same settings. I guess I wait for a new vscode release :(
I would still encourage trying insiders! It's pretty stable for me.