Skip to content

Powershell clear doesn't reset Line rendition attribute while clearing the screen #21176

Open

Description

Prerequisites

Steps to reproduce

  1. Render Double width Double height text
PS> "`e#3SomeText`n`e#4SomeText"
  1. Press enter to fill terminal with some lines of text.

  2. Clear screen with Powershell clear:

PS> clear

Expected behavior

After Step 3, the screen is cleared and newly entered lines are rendered normally.

Actual behavior

After Step 3, the screen is cleared and but the newly entered lines are rendered with its previous line rendition.

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.1
PSEdition                      Core
GitCommitId                    7.4.1
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Video.mp4

Activity

  1. 237dmitry commented on Feb 2, 2024

    @237dmitry

    This is old problem with BufferHeight. Workaround:

    Screenshot 2024-02-02 141130

    Only for terminals with non-dynamic buffer height (conhost). In WT this does not work.

  2. tusharsnx commented on Feb 2, 2024

    @tusharsnx
    Author

    237dmitry How is the workaround better than using the VT seq "`e[3;J`e[H`e[J" ?

  3. 237dmitry commented on Feb 2, 2024

    @237dmitry

    How is the workaround better than using the VT seq "e[3;Je[H`e[J" ?

    I haven't tried it. At the moment I can’t anymore, not all terminals understand #3 #4

    ss

    Linux /usr/bin/clear outputs:

     $ clear > Desktop/clear.txt
     $ cat -v ./Desktop/clear.txt
    ^[[H^[[2J^[[3J
     $ 
    
  4. tusharsnx commented on Feb 2, 2024

    @tusharsnx
    Author
    Linux /usr/bin/clear outputs:

    $ clear > Desktop/clear.txt
    $ cat -v ./Desktop/clear.txt
    ^[[H^[[2J^[[3J
    $

    "`e[H`e[2J`e[3J" works too 👍


    These sequences are more robust than the current Console APIs based screen clearing (Ex1 Vs. Ex 2 & 3), and clear should use virtual terminal sequence based approach.

  5. SteveL-MSFT commented on Feb 5, 2024

    @SteveL-MSFT
    Member

    The Clear-Host function is different on Windows vs non-Windows already. On Windows, it uses the RawUI APIs and based on a comment in the code seems necessary for WinRM based remoting to some Windows systems that are headless. Not sure if it's relevant anymore, otherwise switching to a universal VT escape sequence makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions