vim-dispatch-neovim
vim-dispatch-neovim copied to clipboard
The terminal buffer is sometimes read before being fully written
It seems as if getlinebuf()
in JobExit()
gets the buffer before the terminal is done writing to it. This results in the output being cut.
Might be related to neovim/neovim/issues/4569 or neovim/neovim/issues/3030.
FYI, https://github.com/neovim/neovim/issues/4569 should be fixed now (on nvim master).
Thank you for notifying me! I'll test my plugin with the new version and see if that solves it.
I have this problem at times running against a recent neovim head build. Have you had a chance to look into it?
I have but I haven't found a solution yet. It seems as if neovim closes the output pipes too soon when using the embedded terminal. I'm hoping a fix for neovim/neovim#3030 will solve this.
@radenling could you try this patch? https://github.com/neovim/neovim/issues/3030#issuecomment-233194402
@justinmk that patch didn't make a difference for me.
So, I've been digging into this and as far as I can tell, there are two parts to this problem:
- If the external program exits before the terminal has been updated (it's updated at an interval for performance reasons) you will get an empty result. I have an experimental patch for neovim at radenling/neovim@ffb5d03 which solves this problem.
- If the output from the external program exceeds 4096 bytes (I suppose this limit varies between systems) and output from the program is displayed in a terminal buffer, odds are that some of the output will be dropped. The reason for this is, as I understand it, that the write buffer for the child pseudoterminal becomes full when neovim is busy doing other things (like updating the terminal buffer). When that happens output gets dropped since the pseudoterminal handle is set to be non-blocking and the child doesn't compensate for this (by retrying failed writes).
I haven't really dealt with pseudoterminals and stuff like this before, so I might've gotten things wrong in the second part. I also have no clear solution to the second problem right now.
One way of reproducing this issue I've found is using ack.vim with dispatch support enabled.
Fix (at least for the first problem) will land in 0.2.1: https://github.com/neovim/neovim/pull/6595