Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skip line erasing on render when window size is not yet available #32

Merged
merged 1 commit into from
Feb 13, 2018
Merged

skip line erasing on render when window size is not yet available #32

merged 1 commit into from
Feb 13, 2018

Conversation

bcicen
Copy link
Contributor

@bcicen bcicen commented Feb 12, 2018

In situations where a psuedo tty is allocated (e.g. within a docker container), window size via TIOCGWINSZ is not immediately available and will result in 0,0 dimensions, causing a divide by 0 error when Render() is called before the tty is fully setup.

However, in such circumstances, SIGWINCH is emitted when the psuedo tty allocation is complete. This change allows go-prompt to skip erase / height calculations when the initial window size is fetched (manually) as 0 and proceed as normal once the winch signal is received.

@c-bata
Copy link
Owner

c-bata commented Feb 12, 2018

Oh, I had no idea. Thanks.

// Erasing
r.out.CursorBackward(int(r.col) + len(buffer.Text()) + len(prefix))
r.out.EraseDown()
if r.col > 0 {
Copy link
Owner

@c-bata c-bata Feb 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a following comment before this line?

In situations where a psuedo tty is allocated (e.g. within a docker container), window size via TIOCGWINSZ is not immediately available and will result in 0,0 dimensions.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add after merge this. thanks.

@c-bata c-bata merged commit 5212a86 into c-bata:master Feb 13, 2018
@c-bata c-bata mentioned this pull request Feb 13, 2018
@bcicen bcicen deleted the skip-erase-on-nil-height branch February 14, 2018 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants