microsoft/typescript-go

LSP - ts errors on newly opened files don't show until switching file

Closed this issue · 5 comments

Steps to reproduce

  1. have a ts file with ts errors in it.
  2. open the file - wait a few minutes - no errors show
Image
  1. switch to a different file - errors show immediately (in this case on effects.ts)
Image

so there is some kind of strange new delay in showing errors on unedited files.

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:

  1. close document that has errors
  2. restart tsgo
  3. wait 10 seconds
  4. open document with errors
  5. wait as long as you like - no errors
  6. 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.