Repository navigation
CodeLens: Run commands on completed clicks - #351284
Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 1 commit into
Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 1 commit into
Dmitriy Vasyura (dmitrivMS) wants to merge 1 commit into
Conversation
Opening a native dialog on mouse-down can leave X11 pointer input grabbed. Execute on click instead, keeping an unchanged link attached across provider refreshes and dispatching its latest command arguments. Fixes #133073 Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The CodeLens click handler lacks explicit teardown on replacement, removal, and widget disposal, allowing retained detached targets to retain command and widget/editor callbacks.
1 open issue
What changed in this PR
This PR moves CodeLens command execution from mouse-down to completed clicks, addressing the X11 modal-dialog input lockup while preserving protection against selection drags.
Changes:
- Dispatch commands through link click handlers.
- Preserve unchanged links and icons across refreshes while using the latest command arguments.
- Add a regression test for refresh-spanning clicks and changed-command replacement.
| File | Description |
|---|---|
src/vs/editor/contrib/codelens/test/browser/codelensWidget.test.ts |
Tests target preservation, command replacement, and latest-argument dispatch. |
src/vs/editor/contrib/codelens/browser/codelensWidget.ts |
Reuses unchanged rendered parts and handles completed clicks. |
src/vs/editor/contrib/codelens/browser/codelensController.ts |
Removes mouse-down dispatch and passes command execution callbacks to widgets. |
Review effort: Balanced
| } | ||
| if (command?.id) { | ||
| // Even an unchanged link can have fresh command arguments after a provider refresh. | ||
| part.node.onclick = () => this._executeCommand(command); |
This branch has not been deployed
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.

Fixes #133073.
Run CodeLens commands on a completed click rather than on mouse-down. A native X11 dialog can otherwise open while the pointer is still held, preventing both the dialog and other X11 applications from receiving clicks.
Keep the link and its icon attached when the command ID and visible title at that position are unchanged, but dispatch the latest command arguments. A provider or focus refresh no longer loses the click, and a changed action does not inherit the press. Dragging a selection onto a lens still does not activate it (#107736).
Verification: Manual steps, source-only fixture, and Fedora recording on the issue. Tested real provider/focus refreshes and cancelled gestures in Linux Chromium. Native macOS and Windows were not tested.
Automated checks:
pnpm run build-fast --client-only— passed.node test/unit/browser/index.js --run src/vs/editor/contrib/codelens/test/browser/codelensWidget.test.ts --browser chromium --reporter dot— passed; the refresh assertion failed on the earlier click-only implementation.pnpm run typecheck-client— passed.pnpm run oxlint src/vs/editor/contrib/codelens/browser/codelensController.ts src/vs/editor/contrib/codelens/browser/codelensWidget.ts src/vs/editor/contrib/codelens/test/browser/codelensWidget.test.ts— passed.