lsbench acts as the LSP client. This page covers how it adapts to what a server advertises, and how it answers the server.
rootUri, workspaceFolders and every textDocument.uri are percent encoded file URIs, as Node's pathToFileURL() builds them.
- A workspace path with
#,?,%or a space, such as/tmp/a#b 100%, is sent asfile:///tmp/a%23b%20100%25. - Publishes are matched after decoding, so a server may encode the same characters or not, see publishes.
- The exported
pathToUri()anduriToPath()encode and decode the same way.uriToPath()returns a URI it can't decode, such as one with%2F, unchanged.
A timed request whose provider the server advertises neither statically nor through client/registerCapability isn't sent. It returns null without a round trip and records a timing with result: "skipped" and duration_ms: 0, so it shows in the report as skipped instead of as a fast failure.
- This covers the timed context methods, including
willSaveWaitUntil, andrequest()calls for the same LSP methods. Otherrequest()methods are always sent. - A pulled diagnostics wait on a server without
diagnosticProvideris skipped the same way, and resolves with the cached diagnostics. --no-skip-unsupported(skipUnsupported: false) sends them anyway.- Verbose mode prints which requests the server supports right after startup, and logs dynamic registrations as they arrive.
A server that registers a provider only after initialized gets it skipped until the registration arrives, so wait (for example with waitForDiagnostics) before the first request.
edit follows the server's change sync kind, read from the static textDocumentSync capability (a bare TextDocumentSyncKind number or its change field) and from dynamic textDocument/didChange registrations (syncKind). A dynamic registration overrides the static value. With several registrations the most demanding kind wins (Full over Incremental over None).
| Kind | didChange |
|---|---|
| Incremental (2) | one ranged change per edit |
| Full (1) | one change holding the whole tracked text after the edits, without a range |
| None (0) | not sent, logged in verbose mode. The tracked text and version still update, so later saves and edits stay consistent, but diagnostics waits stay keyed to the didOpen |
An edit range whose start comes after its end is swapped before it is applied locally and sent, so the server receives the same range lsbench applies.
A server that doesn't state a change kind gets incremental changes. The LSP default is None, but every server measured so far that omits it accepts incremental changes, so only an explicit 0 disables didChange.
saveDocument and willSave follow the server's save options, read from the static textDocumentSync capability and from dynamic registrations of textDocument/didSave, textDocument/willSave and textDocument/willSaveWaitUntil.
- A bare
TextDocumentSyncKindnumber impliesdidSavewithout text, matchingvscode-languageclient. - A notification the server doesn't ask for is skipped and logged in verbose mode.
willSaveWaitUntilis a request, so it follows the unsupported requests rule and is recorded as skipped.
lsbench answers requests from the server so it doesn't get stuck waiting on a client:
| Request | Answer |
|---|---|
workspace/workspaceFolders |
the single folder sent in initialize, the workspace root named by its basename |
workspace/configuration |
each item's section resolved against the settings file, or an empty object per item without one |
client/registerCapability, client/unregisterCapability |
accepted, and every registration is tracked (see ctx.registrations) |
workspace/*/refresh (semantic tokens, inlay hints, code lenses, inline values, diagnostics) |
acknowledged. A diagnostics refresh also makes pending auto waits pull |
window/workDoneProgress/create |
acknowledged, and the token is tracked for waitForIdle |
window/showMessageRequest |
dismissed with null |
workspace/applyEdit |
declined with applied: false, so the server never modifies the workspace |
lsbench advertises workspace.didChangeWatchedFiles with dynamic registration, as VS Code does, so servers leave file watching to the client. Their watcher registrations are tracked, but lsbench never sends file events.
Other server messages can be handled by an action script's setup.