Repository navigation
fix: expand selection feature not respecting server textDocument/selectionRange response - #1009
Merged
angelozerr merged 1 commit intoMay 1, 2025
Conversation
`textDocument/selectionRange` response Fixes redhat-developer#1007 Signed-off-by: azerr <[email protected]>
angelozerr
force-pushed
the
selectionRange_word_fix
branch
from
May 1, 2025 07:18
3333f26 to
f53e93d
Compare
angelozerr
marked this pull request as ready for review
May 1, 2025 07:18
lagergren
added a commit
that referenced
this pull request
Nov 23, 2026
…Request event (#2122) ## What Cancelling the future of a DAP request sends `{"type":"event","seq":N,"event":"$/cancelRequest","body":{"id":<seq>}}` to the debug adapter. That isn't DAP: DAP cancels a request with the [`cancel` request](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_Cancel), whose `requestId` is the `seq` of the request. ## Cause LSP4J 1.0.0's `DebugRemoteEndpoint` doesn't override `RemoteEndpoint.sendCancelNotification`. So `JsonRpcRequestFuture.cancel` sends LSP's `$/cancelRequest` notification, and `DebugMessageTypeAdapter` writes it as a DAP event. eclipse-lsp4j/lsp4j#1009 fixes this in LSP4J, but isn't released yet (tracked in #2121). ## Change - `DAPClient.createLauncher` builds its launcher with a `DebugLauncher.Builder` (the new `DAPClientLauncher`). Its `createRemoteEndpoint` is LSP4J's, except that it makes a `DebugRemoteEndpoint` subclass. - That endpoint overrides `sendCancelNotification`: - if the adapter's current capabilities have `supportsCancelRequest`, it sends `cancel` with `requestId` set to the request's `seq`, with LSP4J's `CancelArguments`; - it doesn't wait for the answer, as some adapters, as CodeLLDB, never answer `cancel`, which would leave a pending entry forever; - without the capability, it sends nothing; - either way, the future still ends cancelled locally. - It also drops the answer to such a `cancel`, for which `RemoteEndpoint` would log "Unmatched response message". - Each session, child sessions included, checks the capabilities of its own adapter. - The overrides are marked `// TODO LSP4J:`, to remove once #1009 is released. The capability check stays. ## Behaviour changes None today: LSP4IJ never cancels the future of a DAP request. #2107 (progress and cancel) will, and this is the launcher change it plans. Every message other than `cancel` goes through the same LSP4J code as before. ## Test `DAPClientLauncherTest` creates the launcher against a debug adapter on a loopback socket, and reads the raw frames on the adapter's end: - With `supportsCancelRequest`, the adapter gets one `cancel` request with the cancelled request's `seq`, and then the next request, with no `$/cancelRequest` event. The adapter answers the `cancel`, and LSP4J logs no warning. - Without it, the adapter gets the next request right after the cancelled one. On `main`'s launcher, both tests fail: the adapter gets `{"type":"event","seq":2,"event":"$/cancelRequest","body":{"id":1}}`. The `dap` tests pass on 2024.2, 2025.3 and IU 2026.3 (346 each), and the full suite passes on 2024.2 (1861 tests, 0 failures, 7 skipped).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: expand selection feature not respecting server
textDocument/selectionRangeresponseFixes #1007