git: caeade0e00d5 - stable/12 - vt: fix double-click word selection for first/last word on line
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 25 Feb 2022 16:23:05 UTC
The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=caeade0e00d50ec7a2392a3d28d85f2ec535344b commit caeade0e00d50ec7a2392a3d28d85f2ec535344b Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2022-02-21 04:09:36 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-02-24 18:42:48 +0000 vt: fix double-click word selection for first/last word on line Previously when double-clicking on the first word on a line we would select from the cursor position to the end of the word, not from the beginning of the line. Similarly, when double-clicking on the last word on a line we would select from the beginning of the word to the cursor position rather than the end of the line. This is because we searched backward or forward for a space character to mark the beginning or end of a word. Now, use the beginning or end of the line if we do not find a space. PR: 261553 Sponsored by: The FreeBSD Foundation (cherry picked from commit 692bb3f0291b21337eb9a778f71a5b97a47e4c11) (cherry picked from commit 521dbfd6b1085511769c419d44f11842e92067f5) (cherry picked from commit a861b27a45b0fc76bcb0dcf8ca53f1a831a13c2f) --- sys/dev/vt/vt_buf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index be5d23b5d54d..bcc36a2e658f 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -786,12 +786,19 @@ vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row) break; } } + /* No space - word extends to beginning of line. */ + if (i == -1) + vb->vb_mark_start.tp_col = 0; for (i = col; i < vb->vb_scr_size.tp_col; i ++) { if (TCHAR_CHARACTER(r[i]) == ' ') { vb->vb_mark_end.tp_col = i; break; } } + /* No space - word extends to end of line. */ + if (i == vb->vb_scr_size.tp_col) + vb->vb_mark_end.tp_col = i; + if (vb->vb_mark_start.tp_col > vb->vb_mark_end.tp_col) vb->vb_mark_start.tp_col = vb->vb_mark_end.tp_col; break;