AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.09k stars 352 forks source link

Select doesn't erase previous prompt in Konsole #300

Closed System-Glitch closed 3 years ago

System-Glitch commented 4 years ago

image

When I press an arrow (or a key for filtering) in a select question, the whole question and options are rewritten.

OS: Ubuntu 20.04 Terminal: Konsole 19.12.3 / Bash Lib version: v2.1.1

This works properly when run from the VSCode integrated terminal but not from Konsole.

This is from Github CLI usage, but it reproduces when I copy, paste and run the example in the README.

Related to #101, it looks like the issue in this comment is exactly the same.

infalmo commented 4 years ago

It seems to be a problem in Konsole with this library. This library works good on all common terminals, except Konsole. Also, escape characters work well on Konsole, so it seems to be a problem in this library.

Needs to be investigated...

System-Glitch commented 4 years ago

I investigated, and I believe I found the cause: resetPrompt was using PreviousLine() instead of Up().

PreviousLine() prints \e[1F, which is apparently not recognized by Konsole. I didn't find this control code anywhere in VT100 and ANSI references. On the other hand, Up() writes \e[1A, which works as expected. Using this makes it work perfectly in both the VSCode integrated terminal and Konsole. This would require a little bit of testing on Windows and MacOS though, but this is a good starting point.

I will open a PR very soon.

infalmo commented 4 years ago

@AlecAivazis Can this be merged, since this is a critical issue?

AlecAivazis commented 4 years ago

@infixint943 i appreciate your enthusiasm but we need to thoroughly test these changes before merging them.