CLS doesn't work in the VT alternate buffer #1580

Closed
opened 2026-01-30 22:31:02 +00:00 by claunia · 5 comments
Owner

Originally created by @lesleyxyz on GitHub (Jun 9, 2019).

Originally assigned to: @carlos-zamora on GitHub.

Environment

Windows build number: [Version 10.0.18362.145]

Windows Terminal version (if applicable): n/a

Any other software? wsl, nano

Steps to reproduce

  1. In either powershell or cmd in terminal, type wsl nano
  2. Execute taskkill -im wsl.exe -f to kill wsl
  3. Type cls in the terminal where wsl was open

Expected behavior

cls should clear the screen and make the terminal behave like it used to before wsl nano

Actual behavior

after killing wsl powershell/cmd is in a bugged state because nano takes up the whole screen
cmd: cls won't clear the screen (first screenshot)
powershell: cls will clear screen BUT if the user inputs e.g. "cls", terminal will print "cclcls", yet still interpret it as "cls" (second screenshot)

L0030755

L0030807

This issue is also present in the original cmd/powershell.

Originally created by @lesleyxyz on GitHub (Jun 9, 2019). Originally assigned to: @carlos-zamora on GitHub. # Environment ```none Windows build number: [Version 10.0.18362.145] Windows Terminal version (if applicable): n/a Any other software? wsl, nano ``` # Steps to reproduce 1) In either powershell or cmd in terminal, type `wsl nano` 2) Execute `taskkill -im wsl.exe -f` to kill wsl 3) Type `cls` in the terminal where wsl was open <!-- A description of how to trigger this bug. --> # Expected behavior `cls` should clear the screen and make the terminal behave like it used to before `wsl nano` <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> # Actual behavior after killing `wsl` powershell/cmd is in a bugged state because nano takes up the whole screen cmd: cls won't clear the screen (first screenshot) powershell: cls will clear screen BUT if the user inputs e.g. "cls", terminal will print "cclcls", yet still interpret it as "cls" (second screenshot) ![L0030755](https://user-images.githubusercontent.com/5853564/59160360-47df6280-8ad5-11e9-8d15-6ee4f756ef15.png) ![L0030807](https://user-images.githubusercontent.com/5853564/59160417-013e3800-8ad6-11e9-986a-ee5621c97d8f.png) This issue is also present in the original cmd/powershell. <!-- What's actually happening? -->
Author
Owner

@zadjii-msft commented on GitHub (Jun 10, 2019):

Well this isn't a terminal-specific problem, this totally repros in conhost too.

There's a lot more bugged here too, like the fact that backspace will delete the entire word, and the arrow keys don't work - they're stuck in VT input mode. Presumably for each of cmd.exe and powershell, if the attached process exits uncleanly, they don't restore the input mode. At least for cmd.exe, this will 100% not get fixed.

I'm kinda curious that cls doesn't work from cmd in this state, but I'd be scared to find out why.

@zadjii-msft commented on GitHub (Jun 10, 2019): Well this isn't a terminal-specific problem, this totally repros in conhost too. There's a lot more bugged here too, like the fact that backspace will delete the entire word, and the arrow keys don't work - they're stuck in VT input mode. Presumably for each of cmd.exe and powershell, if the attached process exits uncleanly, they don't restore the input mode. At least for cmd.exe, this will 100% not get fixed. I'm kinda curious that `cls` doesn't work from cmd in this state, but I'd be scared to find out why.
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 10, 2019):

Two things here.

  1. cls doesn't work in the alternate buffer. When you run cls it actually goes and clears the main buffer. That shouldn't be happening.
  2. Killing any application in any terminal emulator after it has entered a non-default mode (alt screen buffer, SGR mouse mode, margins, scroll regions, etc.) always ends poorly. It's just not a supportable scenario.
@DHowett-MSFT commented on GitHub (Jun 10, 2019): Two things here. 1. `cls` doesn't work in the alternate buffer. When you run `cls` it actually goes and clears the _main buffer_. That shouldn't be happening. 2. Killing any application in _any terminal emulator_ after it has entered a non-default mode (alt screen buffer, SGR mouse mode, margins, scroll regions, etc.) always ends poorly. It's just not a supportable scenario.
Author
Owner

@lesleyxyz commented on GitHub (Jun 10, 2019):

Thank you for both of your replies, these are some new interesting things that I get to learn.
If this is not a supportable scenario, shall I close this issue? Or will this still be tracked?

@lesleyxyz commented on GitHub (Jun 10, 2019): Thank you for both of your replies, these are some new interesting things that I get to learn. If this is not a supportable scenario, shall I close this issue? Or will this still be tracked?
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 10, 2019):

Nah, we'll take the first bullet point here as a bug, which it well and truly is 😄 Thanks for reporting!

@DHowett-MSFT commented on GitHub (Jun 10, 2019): Nah, we'll take the first bullet point here as a bug, which it well and truly is :smile: Thanks for reporting!
Author
Owner

@ghost commented on GitHub (Sep 24, 2019):

:tada:This issue was addressed in #2729, which has now been successfully released as Windows Terminal Preview v0.5.2661.0.🎉

Handy links:

@ghost commented on GitHub (Sep 24, 2019): :tada:This issue was addressed in #2729, which has now been successfully released as `Windows Terminal Preview v0.5.2661.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v0.5.2661.0) * [Store Download](https://www.microsoft.com/store/apps/9n0dx20hk701?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1580