diff --git a/docs/changelog.rst b/docs/changelog.rst index b20ec57f1..f8980c94a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -56,6 +56,8 @@ Detailed list of changes - Fix a regression caused by rewrite of kittens to Go that made various kittens reset colors in a terminal when the colors were changed by escape code (:iss:`6708`) +- Fix trailing bracket not ignored when detecting a multi-line URL with the trailing bracket as the first character on the last line (:iss:`6710`) + 0.30.1 [2023-10-05] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/screen.c b/kitty/screen.c index 58a8c40f8..f5f340314 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -2833,6 +2833,7 @@ static void extend_url(Screen *screen, Line *line, index_type *x, index_type *y, char_type sentinel, bool newlines_allowed) { unsigned int count = 0; bool has_newline = false; + index_type orig_y = *y; while(count++ < 10) { has_newline = !line->gpu_cells[line->xnum-1].attrs.next_char_was_wrapped; if (*x != line->xnum - 1 || (!newlines_allowed && has_newline)) break; @@ -2842,6 +2843,7 @@ extend_url(Screen *screen, Line *line, index_type *x, index_type *y, char_type s next_line_starts_with_url_chars = line_startswith_url_chars(line); has_newline = !line->attrs.is_continued; if (next_line_starts_with_url_chars && has_newline && !newlines_allowed) next_line_starts_with_url_chars = false; + if (sentinel && next_line_starts_with_url_chars && line->cpu_cells[0].ch == sentinel) next_line_starts_with_url_chars = false; } line = screen_visual_line(screen, *y + 1); if (!line) break; @@ -2849,6 +2851,12 @@ extend_url(Screen *screen, Line *line, index_type *x, index_type *y, char_type s if (!new_x && !line_startswith_url_chars(line)) break; *y += 1; *x = new_x; } + if (sentinel && *x == 0 && *y > orig_y) { + line = screen_visual_line(screen, *y); + if (line && line->cpu_cells[0].ch == sentinel) { + *y -= 1; *x = line->xnum - 1; + } + } } static char_type diff --git a/kitty_tests/screen.py b/kitty_tests/screen.py index d7935ad91..27846aad7 100644 --- a/kitty_tests/screen.py +++ b/kitty_tests/screen.py @@ -1007,6 +1007,7 @@ class TestScreen(BaseTest): s.draw(before + url + after) ae(url, x=x + 1 + len(before), y=y) + t('http://moo.com') t('http://moo.com/something?else=+&what-') for (st, e) in '() {} [] <>'.split(): @@ -1016,6 +1017,7 @@ class TestScreen(BaseTest): for trailer in '{([': t('http://moo.com', after=trailer) t('http://moo.com', x=s.columns - 9) + t('https://wraps-by-one-char.com', before='[', after=']') def test_prompt_marking(self): s = self.create_screen()