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

"Update import from ..." quick fix doesn't trigger when clicked if on top of code lens #169854

Closed
yume-chan opened this issue Dec 22, 2022 · 7 comments · Fixed by #191113
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-code-actions Editor inplace actions (Ctrl + .) insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@yume-chan
Copy link
Contributor

Type: Bug

  1. Click the blue light bulb
  2. Click the "Update import from ..." quick fix

🐛: Quick fix widget closes, but no import updated

Recording.2022-12-22.234211.mp4

VS Code version: Code - Insiders 1.75.0-insider (42814d1, 2022-12-22T05:21:47.548Z)
OS version: Windows_NT x64 10.0.25267
Modes:
Sandboxed: Yes

System Info
Item Value
CPUs AMD Ryzen 5 5600X 6-Core Processor (12 x 3700)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 31.91GB (12.14GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (34)
Extension Author (truncated) Version
Bookmarks ale 13.3.1
smart-clicks ant 0.1.1
vscode-zipfs arc 3.0.0
vscode-eslint dba 2.3.0
gitlens eam 13.2.0
prettier-vscode esb 9.10.3
copilot-nightly Git 1.65.7761
remotehub Git 0.49.2022122201
rest-client hum 0.25.1
vscode-env Iro 0.1.0
search-node-modules jas 1.3.0
fluent-icons mig 0.0.18
vscode-docker ms- 1.23.3
remote-containers ms- 0.268.0
remote-ssh ms- 0.95.2022122215
remote-ssh-edit ms- 0.84.0
remote-wsl ms- 0.72.0
hexeditor ms- 1.9.9
js-debug-nightly ms- 2022.12.1417
live-server ms- 0.5.2022122201
remote-explorer ms- 0.1.2022121209
remote-repositories ms- 0.26.0
vscode-typescript-next ms- 5.0.202212210
vsliveshare ms- 1.0.5788
abracadabra nic 6.17.0
material-icon-theme PKi 4.23.0
prisma Pri 4.8.0
vscode-yaml red 1.11.10112022
vscode-sort-json ric 1.20.0
reveal smu 1.2.7
code-spell-checker str 2.12.0
luna-paint Tyr 0.16.0
markdown-all-in-one yzh 3.5.0
material-theme zhu 3.15.6
@mjbvz
Copy link
Collaborator

mjbvz commented Jan 3, 2023

I can't reproduce this issue. Can you please try putting together a small example project that demonstrates this problem

@mjbvz mjbvz added info-needed Issue requires more information from poster typescript Typescript support issues javascript JavaScript support issues labels Jan 3, 2023
@yume-chan
Copy link
Contributor Author

yume-chan commented Jan 3, 2023

Did some debugging, this issue triggers when code fix menu item is overlapping with CodeLens. It doesn't matter what the code fix is. For example in a JavaScript file:

module.exports = { a: 1 } // Invoke code fix menu on `module`, add/remove empty lines below to make some menu item overlapping with CodeLens below


// enable `"javascript.referencesCodeLens.enabled": true`, there will be a CodeLens here
function foo() {

}
compress.mp4

private static _hitTestViewZone(ctx: HitTestContext, request: ResolvedHitTestRequest): IMouseTarget | null {
const viewZoneData = ctx.getZoneAtCoord(request.mouseVerticalOffset);
if (viewZoneData) {
const mouseTargetType = (request.isInContentArea ? MouseTargetType.CONTENT_VIEW_ZONE : MouseTargetType.GUTTER_VIEW_ZONE);
return request.fulfillViewZone(mouseTargetType, viewZoneData.position, viewZoneData);
}
return null;
}

The editor intercepts the event because this hit test found a match. Not sure what "view zone" is, but looking at my original reproduce, there is a CodeLens there.

@vscodenpa
Copy link

Hey @mjbvz, this issue might need further attention.

@yume-chan, you can help us out by closing this issue if the problem no longer exists, or adding more information.

@yume-chan
Copy link
Contributor Author

@mjbvz Please try again using the new repro step above. It's still reproducible in latest insiders version.

@mjbvz mjbvz added this to the May 2023 milestone Apr 24, 2023
@mjbvz mjbvz added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels May 10, 2023
@mjbvz
Copy link
Collaborator

mjbvz commented May 10, 2023

Thank you @yume-chan! I can repo now

@alexdima I believe the root cause is that our editor mouse handlers don't know about context views. In this instance, clicking in the action widget fires mouseDown here:

protected _onMouseDown(e: EditorMouseEvent, pointerId: number): void {

This code ends up thinking that the user has clicked on an MouseTargetType.CONTENT_VIEW_ZONE element, which suppresses the mousedown event. This means our code action list never receives a click event

Can you provide some suggestions on how to fix this? I tried adding a new PartFingerprint.ContextView enum value but then realized the context view service can't use PartFingerprint because it lives in base

@mjbvz mjbvz added editor-code-actions Editor inplace actions (Ctrl + .) and removed typescript Typescript support issues javascript JavaScript support issues labels May 10, 2023
@mjbvz mjbvz changed the title "Update import from ..." quick fix doesn't trigger on mouse click "Update import from ..." quick fix doesn't trigger when clicked if on top of code lens May 15, 2023
@mjbvz mjbvz modified the milestones: May 2023, June 2023 May 15, 2023
@malinthar
Copy link

I could reproduce the same with Ballerina vscode extension as depicted below.
code_actions_new

When I select an item from the context menu on a code lens it selects the public token as depicted above(triggers a mouseDown event). This prevents the selected item (code action) from executing. However, if I selected the same somewhere else (not on code lens) it does not trigger such a event and the code action executes fine.

@alexdima
Copy link
Member

alexdima commented Jul 18, 2023

I see. The root problem is that we add a foreign dom node to the editor dom node via direct DOM APIs and that is unexpected to the mouse handling logic. The foreign dom nodes added to the editor have so far been added via API (content widgets, overlay widgets, etc.).

alexdima added a commit that referenced this issue Aug 23, 2023
Fixes #169854: ignore surprising dom nodes
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Aug 23, 2023
@amunger amunger added the verified Verification succeeded label Aug 29, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-code-actions Editor inplace actions (Ctrl + .) insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants