feat: select entire URL on double-click#10132
Merged
mitchellh merged 2 commits intoghostty-org:mainfrom Jan 7, 2026
Merged
Conversation
mitchellh
requested changes
Jan 2, 2026
Contributor
mitchellh
left a comment
There was a problem hiding this comment.
Was this AI? We require AI be disclosed.
I offered some review. I like the general idea but I think the implementation can be cleaner.
60f6517 to
6759844
Compare
Contributor
Author
Yes, I used Opus to help with this and reviewed/tested the code myself. Thanks for the feedback. I've refactored to unify the functions as you suggested. |
Contributor
Author
2026-01-02.at.23.21.45.-.Gold.Platypus.mp4 |
When double-clicking text, first check if the position is part of a URL using the default URL regex pattern. If a URL is detected, select the entire URL instead of just the word. This follows the feedback from PR ghostty-org#2324 to modify the selection behavior rather than introducing a separate selectLink function. The implementation uses the existing URL regex from config/url.zig which already handles various URL schemes (http, https, ftp, ssh, etc.) and file paths. The URL detection runs before the normal word selection, falling back to selectWord if no URL is found at the clicked position.
8d2624f to
6659315
Compare
mitchellh
approved these changes
Jan 7, 2026
Contributor
mitchellh
left a comment
There was a problem hiding this comment.
Made a couple tweaks (see my added commit). But looks good now. Thanks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
When double-clicking on a URL like
https://example.com, onlyhttpsor//example.comgets selected because:and/are word boundaries. Users expect the entire URL to be selected.How
Added URL detection to the double-click handler in
Surface.zig:selectWord, try to detect if the clicked position is part of a URLThe implementation:
DerivedConfig.links(no per-click compilation)linkAtPosWhat
src/Surface.zig: AddedurlAtPin()helper function and modified double-click handlersrc/terminal/StringMap.zig: Added 2 tests for URL detection following existing test patterns