Only open a URL on the initial button press - #1109
Open
Glen-Tigera wants to merge 1 commit into
Open
Conversation
Ctrl+double-clicking a URL opens it twice. GDK delivers a double-click as BUTTON_PRESS, BUTTON_RELEASE, BUTTON_PRESS, _2BUTTON_PRESS; the URL branch of on_buttonpress tests only event.button and the Ctrl modifier, so both the second BUTTON_PRESS and the _2BUTTON_PRESS reach open_url and the browser gets two tabs for one gesture. The same happens with a single click when link_single_click is enabled, and with mouse switch bounce that lands inside the double-click interval. The existing _2BUTTON_PRESS guard near the top of the handler only covers Gtk.VScrollbar, not the terminal widget. Gate the URL branch on event.type == Gdk.EventType.BUTTON_PRESS. Later event types fall through to the closing `return False`, so VTE still handles double-click word selection and triple-click line selection as before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Problem
Ctrl+double-clicking a URL opens it twice — the browser gets two tabs for one gesture.
GDK delivers a double-click as
BUTTON_PRESS,BUTTON_RELEASE,BUTTON_PRESS,_2BUTTON_PRESS. The URL branch ofon_buttonpresstests onlyevent.buttonand the Ctrl modifier:so both the second
BUTTON_PRESSand the_2BUTTON_PRESSreachopen_url(). The_2BUTTON_PRESSguard near the top of the handler only coversGtk.VScrollbar, not the terminal widget.Same symptom in two other situations:
link_single_clickenabled — an ordinary double-click on a URL opens two tabsFix
Gate the URL branch on
event.type == Gdk.EventType.BUTTON_PRESS.Later event types fall through to the handler's closing
return False, so VTE keeps handling double-click word selection and triple-click line selection exactly as before — only the duplicateopen_url()calls go away.Testing
Reproduced and verified on 2.1.3 (Ubuntu noble, GTK3, Wayland session, VTE 7600), with both link paths — OSC-8 hyperlinks via
hyperlink_check_eventand plain URLs via the regexmatch_check_event. Ctrl+double-click gave two browser tabs before the change and one after. Word and line selection unaffected.🤖 Generated with Claude Code