Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Linux pwsh enables DECCKM, but Windows pwsh cannot handle it; arrow keys stop working after exiting linux powershell #12268

Copy link
Copy link
@DHowett-MSFT

Description

@DHowett-MSFT
Issue body actions

Steps to reproduce

  1. Use Windows PowerShell 7 and PowerShell 7 in WSL.
  2. Launch Windows Powershell in Windows Terminal
  3. Launch wsl, pwsh
  4. Exit Linux powershell
  5. Observe the arrow keys

Linux powershell emits the escape sequence DECSET DECCKM[1] on startup before it emits the first prompt.

This reconfigures the cursor keys, which usually emit CSI A...D, to emit SS3 A...D instead.

Linux powershell can handle SS3 arrow key sequences. This is fine.

When Linux powershell exits, it does not restore DECCKM to its original state. All applications that manipulate global terminal state are expected to return the terminal to "normal" once they are done.

Because the state is not restored when you exit Linux powershell, Windows powershell (which doesn't know that the terminal state has been changed) will start to receive SS3 arrow key sequences.

Windows powershell cannot handle SS3 arrow key sequences, and it ignores them, so the arrow keys do not work.

This also reproduces when you SSH to a linux machine, but WSL is easier for a self-contained repro.

Expected behavior

DECCKM is disabled on exit.

Actual behavior

DECCKM remains enabled on exit, downstream applications get confused.

Environment data

(dhowett-sl) ~ % $PSVersionTable

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

(dhowett-sl) ~ % wsl pwsh -c '\$PSVersionTable'

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Linux 4.19.84-microsoft-standard #1 SMP Wed Nov 13 11:44:37 UTC 2019
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

[1] Notes about DECCKM

CSI ? Pm h
          DEC Private Mode Set (DECSET).
            Ps = 1  ⇒  Application Cursor Keys (DECCKM), VT100.

DECCKM reconfigures the arrow keys as follows

Key            Normal     Application
-------------+----------+-------------
Cursor Up    | CSI A    | SS3 A
Cursor Down  | CSI B    | SS3 B
Cursor Right | CSI C    | SS3 C
Cursor Left  | CSI D    | SS3 D
-------------+----------+-------------

[2] I've investigated PowerShell, PSReadline and dotnet/runtime, and I cannot determine where DECCKM is being enabled.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.