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

Crash when typing before prompt is ready #249

Closed
sophiajt opened this issue Jul 30, 2019 · 7 comments
Closed

Crash when typing before prompt is ready #249

sophiajt opened this issue Jul 30, 2019 · 7 comments
Labels

Comments

@sophiajt
Copy link

sophiajt commented Jul 30, 2019

If there is leftover text in the buffer, or you type too soon before rustyline is ready, I'm seeing that it looks like we trip over this and crash:

rustyline/src/tty/unix.rs

Lines 653 to 658 in 9d67a19

if rdr.next_char()? != '\x1b' {
return Err(error::ReadlineError::from(io::ErrorKind::InvalidData));
}
if rdr.next_char()? != '[' {
return Err(error::ReadlineError::from(io::ErrorKind::InvalidData));
}

It seems like it might be where the ansi doesn't see the correct answers coming back.

Here's what the output looks like:

Screenshot from 2019-07-30 13-52-15

I wonder if it might be possible to clear (or maybe lock?) the input buffer before rustyline is ready, so that it doesn't interfere with rustyline getting ready to read input.

@gwenn gwenn added the bug label Jul 30, 2019
@gwenn
Copy link
Collaborator

gwenn commented Jul 30, 2019

Maybe related to #246 (same cause).
A quick fix would be to skip checking the cursor position if some bytes are already available in stdin.

@gwenn
Copy link
Collaborator

gwenn commented Jul 30, 2019

https://github.com/prompt-toolkit/python-prompt-toolkit/blob/master/prompt_toolkit/application/application.py#L874

        # Note: only do this if the input queue is not empty, and a return
        # value has not been set. Otherwise, we won't be able to read the
        # response anyway.

@gwenn
Copy link
Collaborator

gwenn commented Jul 30, 2019

See #250

@sophiajt
Copy link
Author

sophiajt commented Aug 1, 2019

I haven't seen this issue since the PR, so this may have fixed it.

@gwenn
Copy link
Collaborator

gwenn commented Aug 1, 2019

#250 also fixes a similar issue:
#246 (comment)
Thank you for your detailed report.
I will release version 5.0.1.

@gwenn
Copy link
Collaborator

gwenn commented Aug 1, 2019

Version 5.0.1 released

@gwenn gwenn closed this as completed Aug 1, 2019
@sophiajt
Copy link
Author

sophiajt commented Aug 1, 2019

Thank you!

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

No branches or pull requests

2 participants