diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-06-01 16:58:26 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-06-02 06:11:14 +0000 |
| commit | 974c3acd780c88f3d00a0c73132dcc3733fb1427 (patch) | |
| tree | fd51b7e99a57c74f01713e12e38443abd4cc446c /url-mode.c | |
| parent | Merge branch 'document-terminfo' (diff) | |
url-mode: off-by-one error in end-point column of auto-detected URLs
When an auto-detected URL ended *on* the right-most column, the URL
endpoint was off by one, resulting in the underline in URL mode being
one character short.
Diffstat (limited to 'url-mode.c')
| -rw-r--r-- | url-mode.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -320,14 +320,16 @@ auto_detected(const struct terminal *term, enum url_action action, break; } - if (c >= term->cols - 1 && row->linebreak) + if (c >= term->cols - 1 && row->linebreak) { + /* + * Endpoint is inclusive, and we’ll be subtracting + * 1 from the column when emitting the URL. + */ + c++; emit_url = true; + } if (emit_url) { - /* Heuristic to remove trailing characters that - * are valid URL characters, but typically not at - * the end of the URL */ - bool done = false; struct coord end = {c, r}; if (--end.col < 0) { @@ -335,6 +337,10 @@ auto_detected(const struct terminal *term, enum url_action action, end.col = term->cols - 1; } + /* Heuristic to remove trailing characters that + * are valid URL characters, but typically not at + * the end of the URL */ + bool done = false; do { switch (url[len - 1]) { case L'.': case L',': case L':': case L';': case L'?': |
