-
Notifications
You must be signed in to change notification settings - Fork 269
fix(misc): target stdout stream explicitly #1202
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
Conversation
Thanks for the PR!
Could you, please, share a link to where this information coming from?
Did you manage to reproduce similar issue as I described there? And this change should fix it, right? |
I've just tried reproducing "<C-z> -> fg -> `<C-z> -> ... -> <C-z> (background is the same as in Neovim)" with and without the change in the PR. Both times I was able to reproduce. So I don't think this fixes the issue. |
@echasnovski Sorry, didn't see that comment yesterday - oops.
This issue stems from a problem I encountered with build2, which only occurred when Neovim was started in the background. The build2 team investigated and discovered that non-blocking streams were the cause. For background, see build2/build2#417
No — I’m unable to reproduce the sync issue at all, so it’s surprising that you can reproduce it on your machine. Why is that? What’s the difference? Who knows, haha. That said, there is a subtle difference between io.write and io.stdout:write when output redirection is involved. io.write writes to the current default output stream, which can be redirected. If the default output stream changes, io.write will respect that redirection. io.stdout:write, on the other hand, always writes to stdout, regardless of any redirection. It specifically targets the stdout stream, which always goes to the terminal (or the original standard output). I think this change is worthwhile if only for that, even though I had hoped it would fix the sync issue on your side, but alas. |
Adding to this, here’s an example to illustrate the difference: local file = io.open("output.txt", "w")
io.output(file)
file:close() In this case, file:close will cause mini.misc (io.write) to error out with:
But io.stdout:write will still work as expected, since it directly writes to stdout, "bypassing" the redirection and file closure. |
Oh, my... You should have started with that. I can reproduce. Will schedule to finish and merge this PR tomorrow. |
Resolve #1202 Co-authored-by: Evgeni Chasnovski <[email protected]>
This now should be part of |
Use explicit targeting to sync the terminal background.
Nvim changes standard streams to non-blocking mode, so we should use io.stdout:write to ensure that writes are handled properly (that is, directly addressing the term's standard output).
This should address the last remaining bits from #1111:Let me know how it goes :)