vt newcons double click does not mark whole word if word starts at beginning of line. Problem description: If one double clicks a word at the beginning of the line, then vt newcons marks only the part of the word past the click coordinate. Example: If one double-clicks on the 'm' in the word "Example:" which starts at the line beginning, only "mple:" gets marked. Expected result: Whole word "Example:" should be marked. Workaround: Mark the word by using placing mouse at beginning/end of section, press left button, move mouse, and then release button.
See VTB_MARK_WORD in sys/dev/vt/vt_buf.c This (untested) patch may fix it: diff --git a/sys/dev/vt/vt_buf.c b/sys/dev/vt/vt_buf.c index 9c9417d6eca4..6aae6054d6c5 100644 --- a/sys/dev/vt/vt_buf.c +++ b/sys/dev/vt/vt_buf.c @@ -814,6 +814,8 @@ vtbuf_set_mark(struct vt_buf *vb, int type, int col, int row) if (TCHAR_CHARACTER(r[i]) == ' ') { vb->vb_mark_start.tp_col = i + 1; break; + } else if (i == 0) { + vb->vb_mark_start.tp_col = i; } } for (i = col; i < vb->vb_scr_size.tp_col; i ++) { (Note that if the word continued from the previous line we would only highlight from the beginning of the line. This would presumably be addressed with more extensive work for PR260963.)
Just tested the patch. The word at the beginning of the line gets marked as whole at double-click now. Well done, thumbs up! Thank you very much, Ed! While testing the patch and looking at vt_buf.c, I found two other issues, however. Please see PR262090 and PR262091.
A commit in branch main references this bug: 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(+)
I committed a slightly different version. By inspection there is a similar issue at the end of a line, although in that case it is very likely that the word extends to the next line.
I have the initial version of the word-at-EOL change in review at https://reviews.freebsd.org/D34339. Properly supporting EOL words that are split to the next row will be part of the eventual fix for PR 260963.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=521dbfd6b1085511769c419d44f11842e92067f5 commit 521dbfd6b1085511769c419d44f11842e92067f5 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2022-02-21 04:09:36 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-02-23 15:53:24 +0000 vt: fix double-click word selection for last word on line Previously when double-clicking on the last word on a line we would select from the beginning of the word to the cursor position, because we searched forward for a space character to find the end of a word. Now, use the end of the line if we do not find a space. PR: 261553 Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34339 sys/dev/vt/vt_buf.c | 4 ++++ 1 file changed, 4 insertions(+)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f6a7ce86fc2d2d13f169ff7b5f147858c445ec67 commit f6a7ce86fc2d2d13f169ff7b5f147858c445ec67 Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2022-02-21 04:09:36 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-02-25 16:22:27 +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) sys/dev/vt/vt_buf.c | 7 +++++++ 1 file changed, 7 insertions(+)
A commit in branch stable/12 references this bug: 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(+)
Fixed in main and supported stable branches, thank you for the report.