typst / webapp-issues

Issue tracker for Typst's web app.
https://typst.app
13 stars 0 forks source link

Jump-to-definition is overly sensitive to Ctrl-key #416

Closed Mc-Zen closed 2 months ago

Mc-Zen commented 3 months ago

Description

Recently, the jump-to-definition has been added to the web app. Ctrl-clicking on a definition moves the cursor to the declaration.

While other code editors only react if the Ctrl-key is pressed down both during the mouse-down and the mouse-up event, the web app seemingly only requires the latter. Therefore, it is possible to 1) press down the left mouse button 2) press down the Ctrl key 3) release the left mouse button to fire the jump-to-definition feature.

This seems like a small difference but it is leading to a really bad experience when using a touchpad (i.e., it's driving me nuts). Dozens of times every day, I quickly select a word or line and immediately press Ctrl-C. As of new, this brings me to the declaration site (if any definition name is under the cursor) where the first line is being copied to the clipboard instead of the intended selection.

Suggested change:

Require the Ctrl-key being hold also already at the mouse-down event in order to fire jump-to-definition. This is in accordance with how other editors implement the feature.

Reproduction URL

No response

Browsers

Microsoft Edge

OS

Windows

abel1502 commented 2 months ago

I'm also suffering from this, as it often accidentally jumps to definition when I'm trying to select a chunk of code and copy it. If I preemptively hold ctrl before making the selection, after I release the mouse button it jumps to definition. This does not happen in any other editor, however, simply requiring ctrl to be held both at mouse-down + mouse-up wouldn't solve it. There also needs to be a distinguishment between a click-and-drag and a full click (mouse-down+mouse-up).

What makes the problem worse is, the back key on the mouse affects browser tabs and not positions in the code editor, when used in the webapp. So while in an IDE it would be trivial to revert an accidental go-to-definition by pressing the back key, here it would have a detrimental effect of going backwards in tab history instead.

laurmaedje commented 2 months ago

I'm aware that this sucks, I am also suffering. Unfortunately, I haven't yet had time to fix it. But it's high on the priority list.

Mc-Zen commented 2 months ago

Nice!! thank you

abel1502 commented 2 months ago

Still not fixed in the webapp. I hope it's just a delay in deployment, but I'll still put this out there just in case.

laurmaedje commented 2 months ago

I think what you do is different from what @reknih fixed. The fix made it such that the ctrl/cmd key needs to be pressed before the click starts. Previously, cmd/ctrl could be pressed after the click started. What you do is click cmd/ctrl even before the selection and then do the selection and hit C. Which is I think a somewhat rare thing to do, but I see how it would still be better to not trigger even in this case.