Another annoying behavior of vt newcons is that it pads the sections after the last character of every line to the end of the screen line with spaces. This makes necessary to manually clean up the paste result, removing that empty whitespace, which can get quite a lot of work if there has been much stuff being pasted. So I'd highly appreciate if that could be fixed, so the behavior is similiar to what one is used from x terminals and good old SC console.
Can you try this with sc(4) (and a 80 col wide terminal): $ printf 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx x\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\nx\n' then copy and paste, and report whether it is three or four lines? xterm handles this correctly (as an 81-char line, and then two at 79 and 1). My suspicion is that sc(4) just strips trailing whitespace, which is not quite correct but preferable.
(In reply to Ed Maste from comment #1) That printf should be all one line, i.e. 79 x's, space, x, newline, 79 x's, newline, x, newline. 00000000 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 00000010 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 00000020 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 00000030 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 00000040 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 20 |xxxxxxxxxxxxxxx | 00000050 78 0a 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |x.xxxxxxxxxxxxxx| 00000060 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 00000070 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 00000080 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 00000090 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 |xxxxxxxxxxxxxxxx| 000000a0 78 0a 78 0a |x.x.| 000000a4
I think you are right. vi (^G) says 4 lines, and every line ends with 'x'. No 0x20 space chars at line ends, also none at the first line. I think both sc and vt lack sort of a "printed flag" for character cells, which X terminals appear to have.
(In reply to Stefan B. from comment #3) So both sc and vt are buggy, but sc's bug is definitely less objectionable. Keeping track of "printed a space" vs "empty" character cells will be needed to properly address this and PR260963, but until that happens we should handle it the same way as sc. Presumably just: for each line in copied region: if RH column contains space copy full line to selection buffer else search backwards to find last non-space char copy line from first col until last non-space to selection buffer add \r\n src reference: vtbuf_extract_marked()
Try this patch: https://reviews.freebsd.org/D35552
^Triage: Assign to committer resolving
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=5fe0a82501cb86278b9aa426c4bf11d992e95aaa commit 5fe0a82501cb86278b9aa426c4bf11d992e95aaa Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2022-06-22 16:38:47 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2022-06-27 08:17:16 +0000 vt: Fix contents of paste buffer for newcons. Trim all word separators from end of line, except for last line and only use '\r' to terminate the pasted lines as expected by TTY. Submitted by: Ivan Quitschal <tezeka@hotmail.com> Differential Revision: https://reviews.freebsd.org/D35552 PR: 263084 MFC after: 1 week Sponsored by: NVIDIA Networking sys/dev/vt/vt_buf.c | 27 ++++++++++++++++++++------- sys/dev/vt/vt_core.c | 5 ++--- 2 files changed, 22 insertions(+), 10 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=9971e6aff1bef3d456172c41a3df3ce7266517cf commit 9971e6aff1bef3d456172c41a3df3ce7266517cf Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2022-06-25 09:17:44 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2022-06-27 08:17:16 +0000 vt: Improve multi lingual word separation. Suggested by: Tomoaki AOKI <junchoon@dec.sakura.ne.jp> Differential Revision: https://reviews.freebsd.org/D35552 PR: 263084 MFC after: 1 week Sponsored by: NVIDIA Networking sys/dev/vt/vt_buf.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
Should be fixed now. Please re-test.
(In reply to Hans Petter Selasky from comment #9) As I've reported on freebsd-current ML, now it's working as expected. *Trailing spaces only listed in switch() of tchar_is_word_separator() are deleted on non-last lines. *Space (tried U+3000 only, though) before U+2007, which is not listed and untouched, on non-last line is sanely kept. *Spaces at the end of last line are sanely kept. Tested on *main at git 1e824ee84f46b4a086bc3c7c528c0762e388bc66 *stable13 at git dac438a9b599cfec13b463a1a8d90283f7ed830f, cherry-picking 2 commits on main including 5fe0a82501cb86278b9aa426c4bf11d992e95aaa 9971e6aff1bef3d456172c41a3df3ce7266517cf and also checked (to be sure) the actual changes with above 2 cherry-picked commits matches the last diff on Phablicator. Additional note: I've tested diffs provided by Phablicator on stable13. So the above are actually re-tests of last diff both on main and stable13. Thanks!
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=4437a2e1ddcb11b125824d5840056690f8e2138a commit 4437a2e1ddcb11b125824d5840056690f8e2138a Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2022-06-22 16:38:47 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2022-07-05 11:42:28 +0000 vt: Fix contents of paste buffer for newcons. Trim all word separators from end of line, except for last line and only use '\r' to terminate the pasted lines as expected by TTY. Submitted by: Ivan Quitschal <tezeka@hotmail.com> Differential Revision: https://reviews.freebsd.org/D35552 PR: 263084 Sponsored by: NVIDIA Networking (cherry picked from commit 5fe0a82501cb86278b9aa426c4bf11d992e95aaa) sys/dev/vt/vt_buf.c | 27 ++++++++++++++++++++------- sys/dev/vt/vt_core.c | 5 ++--- 2 files changed, 22 insertions(+), 10 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=d4dd3c8f8b5b050a24da6fc2b885c301843214a5 commit d4dd3c8f8b5b050a24da6fc2b885c301843214a5 Author: Hans Petter Selasky <hselasky@FreeBSD.org> AuthorDate: 2022-06-25 09:17:44 +0000 Commit: Hans Petter Selasky <hselasky@FreeBSD.org> CommitDate: 2022-07-05 11:42:28 +0000 vt: Improve multi lingual word separation. Suggested by: Tomoaki AOKI <junchoon@dec.sakura.ne.jp> Differential Revision: https://reviews.freebsd.org/D35552 PR: 263084 Sponsored by: NVIDIA Networking (cherry picked from commit 9971e6aff1bef3d456172c41a3df3ce7266517cf) sys/dev/vt/vt_buf.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)