Fix hover detection of URLs not working when hovering over the first colon and slash characters in short URLs

Fixes #1201
This commit is contained in:
Kovid Goyal 2018-12-04 06:52:26 +05:30
parent d5366a421f
commit 47ec372c30
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 13 additions and 0 deletions

View File

@ -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]
------------------------------

View File

@ -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;

View File

@ -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')