-
Notifications
You must be signed in to change notification settings - Fork 815
surface: handle hyperlinks more reliably #3903
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
Conversation
We refresh the link hover state in two (generic) cases 1. When the modifiers change 2. When the cursor changes position Each of these have additional state qualifiers. Modify the qualifiers such that we refresh links under the following scenarios: 1. Modifiers change - Control is pressed (this is handled in the renderer) - Mouse reporting is off OR Mouse reporting is on AND shift is pressed AND we are NOT reporting shift to the terminal 2. Cursor changes position - Control is pressed (this is handled in the renderer) - We previously were over a link - The position changed (or we had no previous position) - Mouse reporting is off OR Mouse reporting is on AND shift is pressed AND we are NOT reporting shift to the terminal This fixes a few issues with the previous implementation: 1. If mouse reporting was on and you were over a link, pressing ctrl would enable link hover state. If you moved your mouse, you would exit that state. The logic in the keyCallback and the cursorPosCallback was not the same. Now, they both check for the same set of conditions 2. If mouse reporting was off, you could hold control and move the mouse to discover links. If mouse reporting was on, holding control + shift would not allow you to discover links. You had to be hovering one when you pressed the modifiers. Previously, we only refreshed links if we *weren't* reporting the mouse event. Now, we refresh links even even if we report a mouse event (ie a mouse motion event with the shift modifier pressed *will* hover links and also report events)
cc @tristan957, @gpanders |
Thanks for finding the proper fix. Next release is gonna be great! |
It's hard to make sense of this logic since it's so poorly tested (something I'm working on). A brief glance this looks okay, and I think it should only affect links if there are bugs in this logic anyways, and links are already a bit buggy. So overall I'm just going to merge this and try to refactor in tests later. Thank you! |
I completely agree. I tried to document when we do this the best I could, but there are lot of moving pieces, as well as opinions. This currently works how I intuitively would think it should, but even then I had some reservations on which behavior is preferred. Ping me once you are ready with your refactor and I can put in some concrete tests to get the behavior exact (and make it easier to discuss the ideal behavior). |
This change has triggered some discussion here that may help to inform the decision about what the correct behaviour is: Personally, I preferred when I didn't need to press shift. This is partly because this is how iTerm behaves (the terminal emulator I was using before Ghostty), but also because I didn't need to be aware of when mouse reporting was enabled when deciding which keys to press. |
Personally, I preferred when I didn't need to press shift. This is partly
because this is how iTerm behaves (the terminal emulator I was using before
Ghostty), but also because I didn't need to be aware of when mouse reporting
was enabled when deciding which keys to press.
I tested a couple terminals before deciding on this behavior, but I don't have
any on my system that have a behavior I like (except for foot, with it's hints -
but this is entirely different). The closest in features is kitty, which has
hover action *without pressing anything*. Having used this for a few days now, I
would agree that it would be nicer to have the functionality be the same whether
capture is on or not, especially since there isn't an obvious way for the user
to know if the application has mouse events on.
|
The plan is to introduce mouse bindings (there's a discussion about it) and let people customize their hyperlink behavior to their heart's content. |
We refresh the link hover state in two (generic) cases
Each of these have additional state qualifiers. Modify the qualifiers
such that we refresh links under the following scenarios:
OR
Mouse reporting is on AND shift is pressed AND we are NOT reporting
shift to the terminal
OR
Mouse reporting is on AND shift is pressed AND we are NOT reporting
shift to the terminal
This fixes a few issues with the previous implementation:
would enable link hover state. If you moved your mouse, you would
exit that state. The logic in the keyCallback and the
cursorPosCallback was not the same. Now, they both check for the same
set of conditions
to discover links. If mouse reporting was on, holding control + shift
would not allow you to discover links. You had to be hovering one
when you pressed the modifiers. Previously, we only refreshed links
if we weren't reporting the mouse event. Now, we refresh links even
even if we report a mouse event (ie a mouse motion event with the
shift modifier pressed will hover links and also report events)
Old Behavior
Notice that the state of the hyperlink is erratic in
comlink
. When I am over it and press ctrl the link is underlined and the url hint in the lower left shown for one frame, but then the state is dropped.old.mp4
New Behavior
State is retained when holding ctrl+shift. And the link only underlines if I press both ctrl+shift. If I move the mouse around while holding these keys, I can discover new links.
new.mp4