Bug 481294 - Sequence <ESC>[3J is implemented incorrectly (should erase whole screen AND clear the scrollback buffer)
Summary: Sequence <ESC>[3J is implemented incorrectly (should erase whole screen AND c...
Status: RESOLVED NOT A BUG
Alias: None
Product: konsole
Classification: Applications
Component: emulation (show other bugs)
Version: 21.12.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-13 15:43 UTC by Mikko Rantalainen
Modified: 2024-02-24 23:02 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikko Rantalainen 2024-02-13 15:43:08 UTC
SUMMARY

According to `man console_codes` the CSI sequence

> ESC [ 3 J: erase whole display including scroll-back buffer

but Konsole implements it as simply clearing the scrollback buffer without erasing the display.

STEPS TO REPRODUCE
1. Run something to have text on screen and scrollback buffer.
2. Execute following command

    printf "\033[3J"

OBSERVED RESULT

Terminal scrollback buffer is deleted but the text visible on the terminal is not touched.

EXPECTED RESULT

There should be no visible text and the scrollback buffer should be empty.

Tested with Ubuntu 22.04 LTS and Konsole version 21.12.3.

$ apt-cache policy konsole
konsole:
  Installed: 4:21.12.3-0ubuntu1
  Candidate: 4:21.12.3-0ubuntu1
  Version table:
 *** 4:21.12.3-0ubuntu1 500
        500 http://fi.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status
Comment 1 ninjalj 2024-02-24 23:02:40 UTC
CSI 3 J comes from xterm, where it only clears the scrollback buffer. VTE (gnome-terminal, xfce-terminal, ...) behaves likewise. Putty also follows that behavior.

See https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s_ :

CSI Ps J  Erase in Display (ED), VT100.
            Ps = 0  ⇒  Erase Below (default).
            Ps = 1  ⇒  Erase Above.
            Ps = 2  ⇒  Erase All.
            Ps = 3  ⇒  Erase Saved Lines, xterm.

So, CSI 2 J erases all the screen, but not the scrollback buffer, while CSI 3 J erases the scrollback buffer, but not the screen.