Skip to content
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

Support for workspace/inlayHint/refresh to ensure inlay hints are correctly shown in editors #13369

Open
fgimian opened this issue Oct 8, 2022 · 6 comments
Labels
A-inlay-hints inlay/inline hints C-bug Category: bug

Comments

@fgimian
Copy link

fgimian commented Oct 8, 2022

Hey there folks, I hope you're all doing well. This issue is related to sublimelsp/LSP-rust-analyzer#80

In editors such as Sublime Text, inlay hints do not show up until an edit is made to a document. As Rafał has mentioned:

Server initially responds with an error to textDocument/inlayHint requests as it's still initializing.

Since in the new spec version there exists a workspace/inlayHint/refresh notification (and we support it), it would be most natural if the server would send it once it finishes loading.

Please see related documentation for workspace/inlayHint/refresh here.

Would you please consider supporting this? 😄

Thanks in advance!
Fotis

@Veykril
Copy link
Member

Veykril commented Feb 9, 2023

Hmm, we should already be sending a refresh notification once we have finished loading.

@Veykril Veykril added C-bug Category: bug A-inlay-hints inlay/inline hints labels Feb 9, 2023
@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Aug 28, 2023

I can confirm that rust-analyzer sends /refresh requests after the corresponding client capability is set, smth. like

lsp_types::ClientCapabilities {
    workspace: Some(lsp_types::WorkspaceClientCapabilities {
        inlay_hint: Some(lsp_types::InlayHintWorkspaceClientCapabilities {
            refresh_support: Some(true),
        }),
        // ... snip
    }),
// ... snip
}

rust-analyzer then sends multiple calls on server startup, and on every change to a file.

I do not quite understand this behavior, honestly: any editors knows beforehand about the change to a file, then communicates the change to the language server and gets back the /refresh request from r-a.
Also, neither editor can know if a server will send any /refresh request at all, the only way to communicate with server about /refresh is described above, in the client capabilities.
Last but not least, /refresh request is global, forcing the editor to invalidate all hints.

Modulo files in the same language server, any change to a file forces the editor to invalidate all opened files' hints — later /refresh does not bring any new information.
After the change, editor propagates the changes to the language server, and either has to wait for /refresh with some timeout, introducing latencies, or do two inlayHint requests in a row for the same state.

Neither makes sense to me, what do I miss?

@Veykril
Copy link
Member

Veykril commented Aug 29, 2023

Ye, maybe the refreshes we do on file changes aren't needed at all. The spec isn't really clear on that as usual

@NobodyNada
Copy link

I'm running into this too. It looks like rust-analyzer does send a workspace/inlayHint/refresh event once the server becomes quiescent, which happens after the workspace is loaded but before indexing. But inlay hints such as type information are not available before indexing has completed.

[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "16/27",      percentage = 59    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "17/27",      percentage = 62    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "18/27",      percentage = 66    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "19/27",      percentage = 70    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "20/27",      percentage = 74    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "21/27",      percentage = 77    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "22/27",      percentage = 81    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "23/27",      percentage = 85    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "24/27",      percentage = 88    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "25/27",      percentage = 92    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      cancellable = false,      kind = "report",      message = "26/27",      percentage = 96    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Roots Scanned",    value = {      kind = "end",      message = "27/27"    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Fetching",    value = {      cancellable = false,      kind = "report",      message = "metadata"    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Fetching",    value = {      kind = "end"    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  id = 17,  jsonrpc = "2.0",  method = "workspace/semanticTokens/refresh"}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  id = 18,  jsonrpc = "2.0",  method = "workspace/inlayHint/refresh"}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "experimental/serverStatus",  params = {    health = "ok",    quiescent = true  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  id = 19,  jsonrpc = "2.0",  method = "window/workDoneProgress/create",  params = {    token = "rustAnalyzer/Indexing"  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Indexing",    value = {      cancellable = false,      kind = "begin",      percentage = 0,      title = "Indexing"    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Indexing",    value = {      cancellable = false,      kind = "report",      message = "0/9 (core + 1 more)",      percentage = 0    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:261	"rpc.send"	{  jsonrpc = "2.0",  method = "$/cancelRequest",  params = {    id = 12  }}
[DEBUG][2023-08-30 11:43:38] .../lua/vim/lsp.lua:1492	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/semanticTokens/full/delta"	{  previousResultId = "1",  textDocument = {    uri = "file:///Users/jnkr/code/osc52/src/main.rs"  }}	<function 1>	1
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:261	"rpc.send"	{  id = 15,  jsonrpc = "2.0",  method = "textDocument/semanticTokens/full/delta",  params = {    previousResultId = "1",    textDocument = {      uri = "file:///Users/jnkr/code/osc52/src/main.rs"    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:380	"server_request: callback result"	{  result = vim.NIL,  status = true}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:261	"rpc.send"	{  id = 17,  jsonrpc = "2.0",  result = vim.NIL}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  error = {    code = -32800,    message = "canceled by client"  },  id = 12,  jsonrpc = "2.0"}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:434	"Received cancellation ack"	{  error = {    code = -32800,    message = "canceled by client"  },  id = 12,  jsonrpc = "2.0"}
[DEBUG][2023-08-30 11:43:38] .../lua/vim/lsp.lua:1492	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/inlayHint"	{  range = {    ["end"] = {      character = 0,      line = 229    },    start = {      character = 0,      line = 130    }  },  textDocument = {    uri = "file:///Users/jnkr/code/osc52/src/main.rs"  }}	<function 1>	1
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:261	"rpc.send"	{  id = 16,  jsonrpc = "2.0",  method = "textDocument/inlayHint",  params = {    range = {      ["end"] = {        character = 0,        line = 229      },      start = {        character = 0,        line = 130      }    },    textDocument = {      uri = "file:///Users/jnkr/code/osc52/src/main.rs"    }  }}
[DEBUG][2023-08-30 11:43:38] .../lua/vim/lsp.lua:1492	"LSP[rust_analyzer]"	"client.request"	1	"textDocument/inlayHint"	{  range = {    ["end"] = {      character = 0,      line = 265    },    start = {      character = 0,      line = 0    }  },  textDocument = {    uri = "file:///Users/jnkr/code/osc52/src/main.rs"  }}	<function 1>	1
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:261	"rpc.send"	{  id = 17,  jsonrpc = "2.0",  method = "textDocument/inlayHint",  params = {    range = {      ["end"] = {        character = 0,        line = 265      },      start = {        character = 0,        line = 0      }    },    textDocument = {      uri = "file:///Users/jnkr/code/osc52/src/main.rs"    }  }}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:380	"server_request: callback result"	{  result = vim.NIL,  status = true}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:261	"rpc.send"	{  id = 18,  jsonrpc = "2.0",  result = vim.NIL}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:380	"server_request: callback result"	{  result = vim.NIL,  status = true}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:261	"rpc.send"	{  id = 19,  jsonrpc = "2.0",  result = vim.NIL}
[DEBUG][2023-08-30 11:43:38] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  jsonrpc = "2.0",  method = "$/progress",  params = {    token = "rustAnalyzer/Indexing",    value = {      cancellable = false,      kind = "report",      message = "1/9 (core)",      percentage = 11    }  }}
[DEBUG][2023-08-30 11:43:39] .../vim/lsp/rpc.lua:364	"rpc.receive"	{  id = 20,  jsonrpc = "2.0",  method = "window/workDoneProgress/create",  params = {    token = "rust-analyzer/flycheck/0"  }}

In this log, rust-analyzer refreshes semantic tokens and inlay hints after the "Roots Scanned" and "Fetching" progress reports, but before "Indexing" begins. My client responds to this event by requesting inlay hints, rust-analyzer responds with nil, and does not send another workspace/inlayHint/refresh event until the document is edited.

bors added a commit that referenced this issue Sep 8, 2023
…eykril

Do not send inlay hint refresh requests on file edits

See #13369 (comment)

Editor itself is able to invalidate hints after edits, and /refresh was sent after editor reports changes to the language server. This forces the editor to either query & invalidate the hints twice after every edit, or wait for /refresh to come before querying the hints.

Both options are rather useless, so instead, send a request on server startup only: client editors do not know when the server actually starts up, this will help to query the initial hints after editor was open and the server was still starting up.
@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Sep 8, 2023

After I open a small project with the file shown on open in VSCode and do not touch anything, I see the following LSP queries:

Rust Analyzer Language Server Trace output
[Trace - 13:54:12] Sending request 'initialize - (0)'.
[Trace - 13:54:12] Received response 'initialize - (0)' in 4ms.
[Trace - 13:54:12] Sending notification 'initialized'.
[Trace - 13:54:12] Sending notification 'textDocument/didOpen'.
[Trace - 13:54:12] Received notification 'experimental/serverStatus'.
[Trace - 13:54:12] Received request 'client/registerCapability - (0)'.
[Trace - 13:54:12] Sending response 'client/registerCapability - (0)'. Processing request took 0ms
[Trace - 13:54:12] Received request 'window/workDoneProgress/create - (1)'.
[Trace - 13:54:12] Sending response 'window/workDoneProgress/create - (1)'. Processing request took 0ms
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Sending request 'textDocument/inlayHint - (1)'.
[Trace - 13:54:12] Received response 'textDocument/inlayHint - (1)' in 0ms.
[Trace - 13:54:12] Sending request 'textDocument/inlayHint - (2)'.
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Sending notification '$/cancelRequest'.
[Trace - 13:54:12] Sending request 'textDocument/inlayHint - (3)'.
[Trace - 13:54:12] Received response 'textDocument/inlayHint - (2)' in 31ms.
[Trace - 13:54:12] Received response 'textDocument/inlayHint - (3)' in 6ms.
[Trace - 13:54:12] Received request 'client/registerCapability - (2)'.
[Trace - 13:54:12] Sending response 'client/registerCapability - (2)'. Processing request took 0ms
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Sending request 'textDocument/foldingRange - (4)'.
[Trace - 13:54:12] Sending request 'textDocument/semanticTokens/range - (5)'.
[Trace - 13:54:12] Received request 'window/workDoneProgress/create - (3)'.
[Trace - 13:54:12] Sending response 'window/workDoneProgress/create - (3)'. Processing request took 0ms
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Received request 'window/workDoneProgress/create - (4)'.
[Trace - 13:54:12] Sending response 'window/workDoneProgress/create - (4)'. Processing request took 0ms
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Received response 'textDocument/foldingRange - (4)' in 4ms.
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Sending request 'textDocument/semanticTokens/full - (6)'.
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:12] Received request 'workspace/semanticTokens/refresh - (5)'.
[Trace - 13:54:12] Sending response 'workspace/semanticTokens/refresh - (5)'. Processing request took 0ms
[Trace - 13:54:12] Received request 'workspace/codeLens/refresh - (6)'.
[Trace - 13:54:12] Sending response 'workspace/codeLens/refresh - (6)'. Processing request took 0ms
[Trace - 13:54:12] Received request 'window/workDoneProgress/create - (7)'.
[Trace - 13:54:12] Sending response 'window/workDoneProgress/create - (7)'. Processing request took 0ms
[Trace - 13:54:12] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received request 'workspace/semanticTokens/refresh - (8)'.
[Trace - 13:54:13] Sending response 'workspace/semanticTokens/refresh - (8)'. Processing request took 0ms
[Trace - 13:54:13] Received request 'workspace/codeLens/refresh - (9)'.
[Trace - 13:54:13] Sending response 'workspace/codeLens/refresh - (9)'. Processing request took 0ms
[Trace - 13:54:13] Received request 'window/workDoneProgress/create - (10)'.
[Trace - 13:54:13] Sending response 'window/workDoneProgress/create - (10)'. Processing request took 0ms
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received request 'window/workDoneProgress/create - (11)'.
[Trace - 13:54:13] Sending response 'window/workDoneProgress/create - (11)'. Processing request took 0ms
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received request 'client/registerCapability - (12)'.
[Trace - 13:54:13] Sending response 'client/registerCapability - (12)'. Processing request took 0ms
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received request 'window/workDoneProgress/create - (13)'.
[Trace - 13:54:13] Sending response 'window/workDoneProgress/create - (13)'. Processing request took 0ms
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received request 'window/workDoneProgress/create - (14)'.
[Trace - 13:54:13] Sending response 'window/workDoneProgress/create - (14)'. Processing request took 0ms
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received request 'window/workDoneProgress/create - (15)'.
[Trace - 13:54:13] Sending response 'window/workDoneProgress/create - (15)'. Processing request took 0ms
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Sending request 'textDocument/documentSymbol - (7)'.
[Trace - 13:54:13] Received response 'textDocument/documentSymbol - (7)' in 1ms.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received request 'workspace/semanticTokens/refresh - (16)'.
[Trace - 13:54:13] Sending response 'workspace/semanticTokens/refresh - (16)'. Processing request took 1ms
[Trace - 13:54:13] Received request 'workspace/codeLens/refresh - (17)'.
[Trace - 13:54:13] Sending response 'workspace/codeLens/refresh - (17)'. Processing request took 0ms
[Trace - 13:54:13] Received request 'workspace/inlayHint/refresh - (18)'.
[Trace - 13:54:13] Sending response 'workspace/inlayHint/refresh - (18)'. Processing request took 0ms
[Trace - 13:54:13] Received notification 'experimental/serverStatus'.
[Trace - 13:54:13] Received request 'window/workDoneProgress/create - (19)'.
[Trace - 13:54:13] Sending response 'window/workDoneProgress/create - (19)'. Processing request took 0ms
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Received notification '$/progress'.
[Trace - 13:54:13] Sending request 'textDocument/codeLens - (8)'.
[Trace - 13:54:14] Received notification '$/progress'.
[Trace - 13:54:14] Received notification '$/progress'.
[Trace - 13:54:15] Received response 'textDocument/codeLens - (8)' in 1165ms.
[Trace - 13:54:15] Received notification '$/progress'.
[Trace - 13:54:15] Received notification '$/progress'.
[Trace - 13:54:15] Received notification '$/progress'.
[Trace - 13:54:15] Received notification '$/progress'.
[Trace - 13:54:15] Received notification '$/progress'.
[Trace - 13:54:16] Received notification 'textDocument/publishDiagnostics'.
[Trace - 13:54:16] Received response 'textDocument/semanticTokens/range - (5)' in 3403ms.
[Trace - 13:54:16] Received response 'textDocument/semanticTokens/full - (6)' in 3307ms.
[Trace - 13:54:16] Sending request 'textDocument/semanticTokens/full/delta - (9)'.
[Trace - 13:54:16] Received response 'textDocument/semanticTokens/full/delta - (9)' in 2ms.

which means rust-analyzer does send a workspace/inlayHint/refresh request, and does that quite late now.

Unfortunately, I still see no hints in VSCode, and neither does it send the textDocument/inlayHint afterwards.
The spec says that delays can be done only if the document is not visible (which is not true):

Note that the client still has the freedom to delay the re-calculation of the inlay hints if for example an editor is currently not visible.

It feels like a bug in VSCode, not in rust-analyzer.
Or, at least, not with /refresh request sending, so I think nothing else can be done for this issue here?
I have also checked it in the editor I work on and it does receive the hint data after that single workspace/inlayHint/refresh request from the server, so VSCode could do that in theory.

@Veykril
Copy link
Member

Veykril commented Sep 8, 2023

an editor is currently not visible.

I think with not visible they mean not focused (as in not rendering) but still open.

It might be a VSCode bug, given they are handling inlay hints in an odd way in general. It waits a second or so with asking for inlay hints after you stopped typing(which is incredibly annoying), so it might just not query for them if the refresh doesn't make it in a certain time interval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inlay-hints inlay/inline hints C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants