Bug 260069 - vt: selected text not cleared upon screen clear or moved upon scroll up
Summary: vt: selected text not cleared upon screen clear or moved upon scroll up
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.2-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Aleksandr Rybalko
URL:
Keywords: vt
: 261584 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-11-26 19:29 UTC by Ed Maste
Modified: 2026-06-11 20:12 UTC (History)
2 users (show)

See Also:
linimon: mfc-stable15?
linimon: mfc-stable14?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2021-11-26 19:29:03 UTC
From https://wiki.freebsd.org/Newcons "Known Issues"
> Having text marked for copy and paste and then launching something that clears
> the screen, f. e. vi(1), leaves the region of previous text still marked. 

I.e.,

1. Run `jot 100`
2. Left click, highlight some lines
3. Run `vi`

Referenced in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211922#c4
Comment 1 Ed Maste freebsd_committer freebsd_triage 2021-11-26 19:56:49 UTC
Similar issue noted in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211922#c7

Reproduction steps:
1. Run `jot 500 | less`
2. Left click, highlight some text
3. Page down - note marked area cleared, as expected
4. Left click, highlight some text
5. Page up or scroll up 1 line at a time, observe marked area not cleared (remains at same location on screen)

pg dn in less produces:
^[[K^M^[[K ^[[KESC^H^H^HESC^[[K[^H[^[[K6^H6^[[K~^H~^M^[[K67^M
("67" here is the first line of the new screen)

So this emits some characters (":", "ESC"), moves the cursor back over them, clears to end of line, etc., but eventually just prints each of the following lines in sequence, letting the window scroll up line by line.
  

pg up in less produces:

^[[K^M^[[K ^[[KESC^H^H^HESC^[[K[^H[^[[K5^H5^[[K~^H~^M^[[K^[[H^[M198^M
^[[H^[M197^M
^[[H^[M196^M
^[[H^[M195^M

This emits the line that will end up at the bottom of the screen ("198"), scrolls down one line, emits the second-from-last line ("197"), and so on.
Comment 2 Ed Maste freebsd_committer freebsd_triage 2022-01-31 19:26:18 UTC
*** Bug 261584 has been marked as a duplicate of this bug. ***
Comment 3 commit-hook freebsd_committer freebsd_triage 2026-05-12 15:56:53 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8db0553ed6d8636d82a26896237099526b93be19

commit 8db0553ed6d8636d82a26896237099526b93be19
Author:     Aleksandr Rybalko <ray@FreeBSD.org>
AuthorDate: 2026-05-12 15:56:20 +0000
Commit:     Aleksandr Rybalko <ray@FreeBSD.org>
CommitDate: 2026-05-12 15:56:20 +0000

    vt: Clear cut-paste selection if the area intersects with the filled region

    * cut-paste buffer stays unchanged

    PR:             260069
    Reported by:    emaste

    Reviewed by:    imp
    Approved by:    imp (mentor)
    Differential Revision:  https://reviews.freebsd.org/D56922

 sys/dev/vt/vt.h      |  2 ++
 sys/dev/vt/vt_buf.c  | 30 ++++++++++++++++++++++++++++++
 sys/dev/vt/vt_core.c |  8 +++++---
 3 files changed, 37 insertions(+), 3 deletions(-)
Comment 4 Alexander Ziaee freebsd_committer freebsd_triage 2026-05-13 00:26:34 UTC
Wow, this is a really nice fix. Can we mfc this?
Comment 5 Aleksandr Rybalko freebsd_committer freebsd_triage 2026-05-13 10:52:00 UTC
(In reply to Alexander Ziaee from comment #4)
Yeah, that was the plan. But lost my MFC row in the commit message :)