diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-03-06 12:06:54 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-03-06 12:06:54 +0000 |
| commit | be980a62825a01b7c3a6b62cf59a3161bf7e0ed5 (patch) | |
| tree | 61d1855dee1ab3f29858c617df121c9d49bd29fa | |
| parent | Merge branch 'consume-modifiers-for-key-bindings' (diff) | |
url-mode: fix auto-detection of URLs in the top corner of the viewport
The ‘proto_chars’ variable is kind of like a FIFO, where characters
from the grid is pushed to the back of it. I.e. the last <n> bytes are
at the *end* of the array.
This was what the protocol matching logic expected. However, it was
only true after reading ‘max_prot_len’ characters from the
grid. Before that, the last <n> bytes from the grid was in
the *beginning* of ‘proto_chars’.
This meant we did not detect URLs starting in the top left corner of
the viewport. Test case:
foot sh -c "echo http://test.com && sleep 9999"
| -rw-r--r-- | url-mode.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -259,11 +259,11 @@ auto_detected(const struct terminal *term, enum url_action action, proto_start[i] = proto_start[i + 1]; } - if (proto_char_count == max_prot_len) - proto_char_count--; + if (proto_char_count >= max_prot_len) + proto_char_count = max_prot_len - 1; - proto_chars[proto_char_count] = wc; - proto_start[proto_char_count] = (struct coord){c, r}; + proto_chars[max_prot_len - 1] = wc; + proto_start[max_prot_len - 1] = (struct coord){c, r}; proto_char_count++; for (size_t i = 0; i < ALEN(prots); i++) { |
