-
Notifications
You must be signed in to change notification settings - Fork 19
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
Calling lock()
on Stdout causes Picker::from_query_stdio()
to fail unhelpfully
#68
Comments
An update: As mentioned, I found I could avoid this problem by either removing
I cannot do this. The way I enter the alternate screen is ¹ I do find I can call |
I think this is outdated or plain wrong. In my latest dog-food-eating at mdfried, I simply call Still, The timeout errors could also be improved probably, to something like "no response from stdin" (or was it stdout?). In general though, the timeouts are leagues better than just halting forever - potentially on some other machine. You are welcome to make some changes! |
@benjajaja , if i make changes it will probably be to the documentation, but before I do that— ""no response from stdin" (or was it stdout?)" Could you clarify what you mean by this? It would help in knowing how the docs should be changed. |
I just pushed 39d62f5 which changes the error from To clarify: we send a query to stdout, and then read back the reply from stdin (with a timeout to avoid blocking forever). So the guidelines should be: 1) both stdout and stdin should not be locked by anything, 2) call |
I have a program based on sample code from the
tui-textarea
widget for Ratatui. I attempted to add ratatui-image to this program and got a failure (for example see: https://github.com/mcclure/tui-textarea , branch "orb-demo", commit7e7341ba
). When run,Picker::from_query_stdio().unwrap()
would fail because from_query_stdio returnedErr(Timeout(Timeout))
. This confused me and I wasn't sure how to proceed (a function which fails instantly with error "Timeout" was confusing to me). After some experimentation and comparing with the ratatui-image samples, I found this was caused by the original tui-textarea code calling.lock()
onio::stdout()
. I don't fully understand why it does this; I assume it's so thatprintln
s later in the program don't splatter nonsense while ratatui is in tui mode. I found I was able to introduce the problem into ratatui-image samples by adding a.lock()
call on the stdout object, and I found I was able to fix the problem in my own code by either removing the.lock()
or moving the call toPicker::from_query_stdio()
to the start of the program, before the.lock()
.Because there is sample code in the wild that suggests locking stdio before initializing crossterm, and all ratatui-image sample code initializes the picker after initializing crossterm, I think this should be considered a problem in ratatui-image. I can think of two ways to mitigate it:
I am willing to write a docs PR myself if it would help.
The text was updated successfully, but these errors were encountered: