Skip to content
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

URLs are opened incorrectly when ending with a closing parenthesis #3688

Closed
sd-trailhead-james opened this issue Jun 3, 2021 · 6 comments
Closed
Labels

Comments

@sd-trailhead-james
Copy link

Describe the bug
If a URL ends with a closing parenthesis ()), Kitty seems to drop the closing parenthesis when opening the URL

To Reproduce
Steps to reproduce the behavior:

  1. Place a URL ending with a closing parenthesis ()) somewhere within Kitty
  2. Attempt to open the URL in the registered browser/handler
  3. Notice that the closing parenthesis ()) is left off of the URL when opened

Example URL: https://www.google.com/search?q=(example)

Screenshots
n/a

Environment details
OS: macOS 11.4 (Big Sur)

Output of kitty --debug-config:

kitty 0.20.3 created by Kovid Goyal
Darwin <REDACTED>.com 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64
ProductName:	macOS ProductVersion:	11.4 BuildVersion:	20F71
Loaded config files: ~/.config/kitty/kitty.conf

Config options different from defaults:
active_border_color                Color(red=150, green=152, blue=150)
active_tab_background              Color(red=29, green=31, blue=33)
active_tab_foreground              Color(red=197, green=200, blue=198)
allow_remote_control               y
background                         Color(red=29, green=31, blue=33)
color0                             Color(red=29, green=31, blue=33)
color1                             Color(red=204, green=102, blue=102)
color10                            Color(red=40, green=42, blue=46)
color11                            Color(red=55, green=59, blue=65)
color12                            Color(red=180, green=183, blue=180)
color13                            Color(red=224, green=224, blue=224)
color14                            Color(red=163, green=104, blue=90)
color2                             Color(red=181, green=189, blue=104)
color3                             Color(red=240, green=198, blue=116)
color4                             Color(red=129, green=162, blue=190)
color5                             Color(red=178, green=148, blue=187)
color6                             Color(red=138, green=190, blue=183)
color7                             Color(red=197, green=200, blue=198)
color8                             Color(red=150, green=152, blue=150)
color9                             Color(red=222, green=147, blue=95)
cursor                             Color(red=197, green=200, blue=198)
enable_audio_bell                  False
font_family                        mononoki
font_size                          16.0
foreground                         Color(red=197, green=200, blue=198)
inactive_border_color              Color(red=40, green=42, blue=46)
inactive_tab_background            Color(red=40, green=42, blue=46)
inactive_tab_foreground            Color(red=180, green=183, blue=180)
macos_custom_beam_cursor           True
macos_quit_when_last_window_closed True
scrollback_lines                   200000
selection_background               Color(red=197, green=200, blue=198)
selection_foreground               Color(red=29, green=31, blue=33)
tab_bar_background                 Color(red=40, green=42, blue=46)
url_color                          Color(red=180, green=183, blue=180)
Added shortcuts:
	 alt+b KeyAction(func='send_text', args=['all', b'\x1bb'])
	 alt+d KeyAction(func='send_text', args=['all', b'\x1bd'])
	 alt+f KeyAction(func='send_text', args=['all', b'\x1bf'])
	 alt+h KeyAction(func='send_text', args=['all', b'\x1bh'])
	 alt+j KeyAction(func='send_text', args=['all', b'\x1bj'])
	 alt+k KeyAction(func='send_text', args=['all', b'\x1bk'])
	 alt+l KeyAction(func='send_text', args=['all', b'\x1bl'])
	 cmd+. KeyAction(func='send_text', args=['all', b'\x03'])

Additional context

Try to reproduce the problem with kitty --config NONE if you cannot then post a minimal kitty.conf that reproduces the problem. If the problem involves interaction with some other terminal program post a minimal config for that program to reproduce the problem as well.

Confirmed that the behavior is identical with kitty --config NONE

@kovidgoyal
Copy link
Owner

This is by design as URLs are often enclosed in parentheses, for example
in markdown like markup languages, therefore closing )}> and other
punctuation is ignored.

One could conceivably make the URL detection look for a matching start
parenthesis, but this is rather too much effort, for me, patches
welcome. Relevant code is in line.c line_url_end_at

Note that you can use the hints kitten
https://sw.kovidgoyal.net/kitty/kittens/hints.html to do much more
sophisticated url matching.

@sd-trailhead-james
Copy link
Author

That makes sense, thank you @kovidgoyal!

@kovidgoyal kovidgoyal reopened this Jun 4, 2021
@rbutoi
Copy link
Contributor

rbutoi commented Jun 16, 2021

Some of the URLs in my terminal are of the form <...noturl... http://url.com>, so this URL sentinel handling wouldn't match it. I currently work around this with a hacky patch which just excludes '>' from the URL characters. Any other thoughts on how to fix this? Perhaps the list of URL characters could be configurable? I could prepare a PR for making it a config option if that's a good idea.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jun 17, 2021 via email

@rbutoi
Copy link
Contributor

rbutoi commented Jun 17, 2021 via email

@kovidgoyal
Copy link
Owner

Add the option in options/definition.py and code to parse it in options/utils.py and code to convert it from python to c in to-c.h, then run ./gen-config.py. See select_by_word_characters as an example.

rbutoi added a commit to rbutoi/kitty that referenced this issue Jun 17, 2021
This option, like select_by_word_characters, is a set of characters, but
for which to *exclude* from URL parsing. See
kovidgoyal#3688 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants