vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Fix context menu inaccurate positioning

Open hsfzxjy opened this issue 1 year ago • 0 comments

This PR should fix #113175, fix #187111.

Previously VSCode adopts a formula like clientX = Math.floor(pageX * zoom) to calculate the coordiate on screen for showing up the context menu. The formula leads to numeric loss when zoom != 1, causing nonnegligible shift of context menu in some cases, and finally presented as user annoyance as described in abovementioned issues.

However, for most of the time the desired position for context menu is the current position of cursor, which actually need not to be calculated by ourselves. Electron Docs states that leaving the x and y arguments as undefined will indicate the context menu popping up at current mouse cursor position.

Therefore, this PR utilizes the Electron API for more accurate context menu popup positioning, and hopefully should fix these related issues, if there's no other defeat in upstream Electron.

hsfzxjy avatar Jul 06 '23 16:07 hsfzxjy