wezterm
wezterm copied to clipboard
Adjust hyperlink rules to handle links containing ")" appropriately (#3803)
The current hyperlink rules match eagerly for link that contain ")" like this:
- (http://localhost/foo)
^^^^^^^^^^^^^^^^^^^^^ --> "http://localhost/foo)"
- [FOO](http://localhost/foo)
^^^^^^^^^^^^^^^^^^^^^ --> "http://localhost/foo)"
This PR makes hyperlink rules match them appropriately like this:
- (http://localhost/foo)
^^^^^^^^^^^^^^^^^^^^ --> "http://localhost/foo"
- [FOO](http://localhost/foo)
^^^^^^^^^^^^^^^^^^^^ --> "http://localhost/foo"
See #3803 for more context.
I think this change breaks "normal" links (ie, surrounded by whitespace). I haven't tested the actual patch, but changed my config to include the regex:
config.hyperlink_rules = wezterm.default_hyperlink_rules()
if config.hyperlink_rules[4].regex == "\\b\\w+://\\S+[)/a-zA-Z0-9-]+" then
config.hyperlink_rules[4].regex = '[^(]\\b(\\w+://\\S+[)/a-zA-Z0-9-]+)'
end
You can see what happens from the logs (patched config, then default config):
16:27:38.527 INFO wezterm_gui::termwindow > clicking https://accounts.myq-cloud.com/api/v6.0/accounts
16:27:49.942 INFO wezterm_gui::termwindow > clicking https://accounts.myq-cloud.com/api/v6.0/accounts
That is, an extra leading space is captured.
I also noticed that any links already in the buffer will not be recalculated, so testing requires something like pasting the link in again, which left me confused for a while. Hopefully I haven't muddled anything up while I've been switching configs around. (Now back to debugging my Home Assistant :))
I think this change breaks "normal" links
Oh, I messed up -- you even mentioned that problem in the review response to @wez... Adding config.hyperlink_rules[4].format = '$1'
and ...highlight = 1
fixes it.
Hello, any progress here? :))
I'm not sure either. If there's an issue, I'm open to fixing it...?
I just haven't had time to review this
I got a similar issue, but the actual link is appended another ".html".
What shows in the console:
- For more details, please see the link (https://foo.com/bar/baz.html)
What shows in the chrome address box: https://foo.com/bar/baz.html).html