Skip to content

Use linkifier2 to double click select links #3230

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

Merged
merged 5 commits into from
Mar 30, 2021

Conversation

marvinthepa
Copy link
Contributor

Also works with right click select.
Fixes #682.

This relies on the fact that before a user (double/right)-clicks a link, the cursor will hover the link, triggering the asynchronous link provider(s). By the time the click event fires, the link provider "should" have done its thing, and the link is used.
If not, this falls back to the old behavior.
This seemed good enough to me. If it is not, one probably would have to expose some inner state of the linkifier to provide some way to check if there are currently link providers resolving and to wait for them to finish before selecting.

I feel a bit bad about duplicating the magic "-1"s (on both x and y for start, only on y for end) from Linkifier2._fireUnderlineEvent, but I couldn't think of a good way to extract that logic.
It seems to me to produce the correct results.

@Tyriar
Copy link
Member

Tyriar commented Jan 26, 2021

Thanks for checking this out, I'm busy testing/stabilizing the next version of VS Code so should get to PRs within the week.

Also works with right click select.
Fixes xtermjs#682.
Tyriar added 2 commits March 30, 2021 05:34
The link range is absolute, not relative to viewport
@Tyriar Tyriar force-pushed the 682_url_selector branch from 2c1df1d to b7e0489 Compare March 30, 2021 13:18
@Tyriar
Copy link
Member

Tyriar commented Mar 30, 2021

This works really well, thanks a bunch!

@Tyriar Tyriar added this to the 4.12.0 milestone Mar 30, 2021
@Tyriar Tyriar self-assigned this Mar 30, 2021
@Tyriar Tyriar enabled auto-merge March 30, 2021 13:25
@Tyriar Tyriar merged commit dd952ac into xtermjs:master Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding smarter double click to select word logic
2 participants