git: 692bb3f0291b - main - vt: fix double-click word selection for first word on line

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 22 Feb 2022 14:12:21 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=692bb3f0291b21337eb9a778f71a5b97a47e4c11

commit 692bb3f0291b21337eb9a778f71a5b97a47e4c11
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-02-21 04:09:36 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-02-22 14:08:50 +0000

    vt: fix double-click word selection for first 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.  This is because we searched backward for a
    space to mark the beginning of a word.
    
    Now, use the beginning of the line if we do not find a space.
    
    PR:             261553
    Reported by:    Stefan B.
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
---
 sys/dev/vt/vt_buf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c
index 9c9417d6eca4..f525e73c8bbe 100644
--- a/sys/dev/vt/vt_buf.c
+++ b/sys/dev/vt/vt_buf.c
@@ -816,6 +816,9 @@ 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;