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

restore cursor on error #337

Merged
merged 1 commit into from Mar 10, 2021
Merged

restore cursor on error #337

merged 1 commit into from Mar 10, 2021

Conversation

noerw
Copy link
Contributor

@noerw noerw commented Feb 27, 2021

This fixes restoring the state of the cursor when an error occurs when detecting terminal size.
fixes #282

Piped stdin is still not handled correctly:
The problem here is, that with piped stdin, Cursor.Location() fails with io.EOF:

survey/terminal/cursor.go

Lines 106 to 109 in f45c05b

text, err := reader.ReadSlice(byte('R'))
if err != nil {
return nil, err
}

Subsequently, no input is read, and control commands printed instead of being applied.

I'm not exactly sure how a piped stdin differs from a terminal stdin, so I don't know how to fix this.
One step surely would be to change Cursor, so that it detects piped stdin, and switches to a NO-OP mode?

If this can't be fixed properly, the README should clearly state that using survey with piped stdin breaks the application.

@AlecAivazis
Copy link
Owner

Hey @noerw - thanks for hunting this down.

Unfortunately, i dont have a lot of time right now to hunt down a better way to address this so I'm fine with adding a notice to the README 👍

@AlecAivazis AlecAivazis merged commit c79c4a9 into AlecAivazis:master Mar 10, 2021
This was referenced Mar 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When .Ask fails, the terminal state isn’t restored
2 participants