diff --git a/docs/changelog.rst b/docs/changelog.rst index a64a68fde..397fac86f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -97,6 +97,9 @@ Changelog - Follow xterm's behavior for the menu key (:iss:`597`) +- Fix hover detection of URLs not working when hovering over the first colon + and slash characters in short URLs (:iss:`1201`) + 0.12.3 [2018-09-29] ------------------------------ diff --git a/kitty/line.c b/kitty/line.c index c45b2764c..8a688add9 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -62,6 +62,13 @@ find_colon_slash(Line *self, index_type x, index_type limit) { do { char_type ch = self->cpu_cells[pos].ch; if (!is_url_char(ch)) return false; + if (pos == x) { + if (ch == ':') { + if (pos + 2 < self->xnum && self->cpu_cells[pos+1].ch == '/' && self->cpu_cells[pos + 2].ch == '/') state = SECOND_SLASH; + } else if (ch == '/') { + if (pos + 1 < self->xnum && self->cpu_cells[pos+1].ch == '/') state = FIRST_SLASH; + } + } switch(state) { case ANY: if (ch == '/') state = FIRST_SLASH; diff --git a/kitty_tests/datatypes.py b/kitty_tests/datatypes.py index fa33f77a8..a474869f0 100644 --- a/kitty_tests/datatypes.py +++ b/kitty_tests/datatypes.py @@ -242,6 +242,9 @@ class TestDataTypes(BaseTest): self.ae(l0.url_end_at(0), len(l0) - 1) l2 = create("http://-abcd] ") self.ae(l2.url_end_at(0), len(l2) - 3) + l3 = create("http://ab.de ") + self.ae(l3.url_start_at(4), 0) + self.ae(l3.url_start_at(5), 0) def lspace_test(n, scheme='http'): lf = create(' ' * n + scheme + '://acme.com')