Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Missing support for DECCKM cursor keys #341

Closed
wez opened this issue Mar 3, 2021 · 5 comments · Fixed by #367
Closed

Missing support for DECCKM cursor keys #341

wez opened this issue Mar 3, 2021 · 5 comments · Fixed by #367

Comments

@wez
Copy link

wez commented Mar 3, 2021

What operating system and terminal are you using?

cli/cli#3071 has more context, but:

  • In any terminal on macos
  • Run powershell (it enables DECCKM)
  • Now run gh auth login
  • Press cursor up or down

What did you expect to see?

The cursor keys should navigate to select one of the login options

What did you see instead?

could not prompt: Unexpected Escape Sequence: ['\x1b' 'O']

Analysis

Due to PowerShell/PowerShell#12268 powershell enables DECCKM which changes the cursor key encoding from CSI A..D to SS3 A..D instead. SS3 is encoded as ESC O in 7-bit encoding.

It is technically a bug that powershell leaves the cursor keys in that mode.
However, it should be pretty simple to support this encoding here in survey:

if r != '[' {
return r, size, fmt.Errorf("Unexpected Escape Sequence: %q", []rune{'\033', r})
}

by allowing either [ or O

@wez
Copy link
Author

wez commented Mar 3, 2021

Another option here is for survey to explicitly disable DECCKM mode on startup so that they key behave the way it wants!

Sending CSI ? 1 l will reset that mode to produce ANSI encoded cursor keys.

@AlecAivazis
Copy link
Owner

Hey @wez - thanks for reporting this! I'm not sure I will have the time to add support for DECCKM but if you wanted to take a shot, i would love to support you however I can. Feel free to reach out on the gophers slack :)

That being said, if you could find the time to disable the mode, it would be much appreciated!

@wez
Copy link
Author

wez commented Apr 16, 2021

I don't have time to do that, however:
PowerShell/PowerShell#12268 (comment)
claims to have resolved the underlying issue in powershell, so it may be OK just to wait for that to become broadly available and do nothing special here.

@coryb
Copy link
Collaborator

coryb commented Jul 22, 2021

We had a user with this issue today on macOS, it seems the fish shell enables the DECCKM mode by default as well. This seems like the related fish issue: fish-shell/fish-shell#2139. That issue lead me to the useful tput rmkx command which resets the terminal back to a mode that works with Survey. To reproduce this error with Survey you can use tput smkx.

@brantb
Copy link

brantb commented Aug 23, 2021

PowerShell 7.2.0-preview.8 no longer exhibits this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants