terminal: Open links with Cmd/Ctrl-click when mouse mode is enabled (#60067)

This fixes #56956.

The terminal link-open gesture was split between `mouse_down` and
`mouse_up`, but both halves only ran in the non-mouse-reporting path.
When a foreground app enabled terminal mouse reporting, a secondary
click on a URL or file path was forwarded to the PTY instead of opening
the link.

This changes secondary-click link handling so it checks for a hyperlink
before mouse reporting on press, and completes the matching hyperlink
open before mouse reporting on release. The event is only consumed when
the click actually lands on the same link, so normal clicks in
mouse-reporting TUIs continue to be forwarded as before.

Validation:

- `CARGO_BUILD_JOBS=1 cargo test -j1 -p terminal
test_hyperlink_ctrl_click_same_position_in_mouse_mode`
- `CARGO_BUILD_JOBS=1 cargo check -j1 -p terminal`

Release Notes:

- Improved terminal links: Cmd/Ctrl-click now opens links even when the
application has mouse reporting enabled (e.g. vim, opencode, claude).
Disable `terminal.open_links_in_mouse_mode` to forward these clicks to
the application instead.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
Tianze ZhaoandSmit Barmase authored and GitHub committed 2026-07-08 12:41:48 +00:00
1 parent 739f23926d
commit f5c975162c
8 files changed
+314 -37

No files matched your search

+21
View File
@@ -4158,6 +4158,7 @@ List of `integer` column numbers
"blinking": "terminal_controlled",
"copy_on_select": false,
"keep_selection_on_copy": true,
"open_links_in_mouse_mode": true,
"dock": "bottom",
"default_width": 640,
"default_height": 320,
@@ -4352,6 +4353,26 @@ List of `integer` column numbers
}
```
### Terminal: Open Links In Mouse Mode
- Description: Whether cmd-click (ctrl-click on Linux and Windows) opens hyperlinks even when the terminal application has enabled mouse reporting (e.g. vim with `mouse=a`, htop). When `false`, these clicks are forwarded to the application instead, and hyperlinks can still be opened with shift-cmd-click (shift-ctrl-click).
- Setting: `open_links_in_mouse_mode`
- Default: `true`
**Options**
`boolean` values
**Example**
```json [settings]
{
"terminal": {
"open_links_in_mouse_mode": false
}
}
```
### Terminal: Env
- Description: Any key-value pairs added to this object will be added to the terminal's environment. Keys must be unique, use `:` to separate multiple values in a single variable