From e86c712424602dff72e78295da01d1998d827dfb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 15 Mar 2020 08:29:56 +0530 Subject: [PATCH] Dont strip :code:`&` and :code:`-` from the end of URLs Fixes #2436 --- docs/changelog.rst | 2 ++ kitty/mouse.c | 4 +++- kitty/unicode-data.h | 2 +- kitty_tests/datatypes.py | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 21cc9df82..870cf31cf 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -72,6 +72,8 @@ To update |kitty|, :doc:`follow the instructions `. - Workaround for bug in less that causes colors to reset at wrapped lines (:iss:`2381`) +- Dont strip :code:`&` and :code:`-` from the end of URLs (:iss:`2436`) + - Fix ``@selection`` placeholder not working with launch command (:iss:`2417`) - Drop support for python 3.5 diff --git a/kitty/mouse.c b/kitty/mouse.c index 70adf4a9d..3e7b0ecbd 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -228,7 +228,9 @@ extend_url(Screen *screen, Line *line, index_type *x, index_type *y, char_type s while(count++ < 10) { if (*x != line->xnum - 1) break; line = screen_visual_line(screen, *y + 1); - if (!line) break; // we deliberately allow non-continued lines as some programs, like mutt split URLs with newlines at line boundaries + if (!line) break; + // we deliberately allow non-continued lines as some programs, like + // mutt split URLs with newlines at line boundaries index_type new_x = line_url_end_at(line, 0, false, sentinel); if (!new_x) break; *y += 1; *x = new_x; diff --git a/kitty/unicode-data.h b/kitty/unicode-data.h index 611c5a17f..c4ea6a893 100644 --- a/kitty/unicode-data.h +++ b/kitty/unicode-data.h @@ -20,7 +20,7 @@ static inline bool can_strip_from_end_of_url(uint32_t ch) { // remove trailing punctuation return ( - (is_P_category(ch) && ch != '/') || + (is_P_category(ch) && ch != '/' && ch != '&' && ch != '-') || ch == '>' ) ? true : false; } diff --git a/kitty_tests/datatypes.py b/kitty_tests/datatypes.py index 21161f03a..755760d1a 100644 --- a/kitty_tests/datatypes.py +++ b/kitty_tests/datatypes.py @@ -281,6 +281,10 @@ def no_url(t): l4 = create(' xxxxxtekljhgdkjgd') self.ae(l4.url_end_at(0), 0) + for trail in '/-&': + l4 = create('http://a.b?q=1' + trail) + self.ae(l4.url_end_at(1), len(l4) - 1) + def rewrap(self, lb, lb2): hb = HistoryBuf(lb2.ynum, lb2.xnum) cy = lb.rewrap(lb2, hb)