vim-dispatch-neovim icon indicating copy to clipboard operation
vim-dispatch-neovim copied to clipboard

The terminal buffer is sometimes read before being fully written

Open radenling opened this issue 8 years ago • 9 comments

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.

radenling avatar May 26 '16 20:05 radenling

FYI, https://github.com/neovim/neovim/issues/4569 should be fixed now (on nvim master).

justinmk avatar Jul 15 '16 02:07 justinmk

Thank you for notifying me! I'll test my plugin with the new version and see if that solves it.

radenling avatar Jul 16 '16 14:07 radenling

I have this problem at times running against a recent neovim head build. Have you had a chance to look into it?

semanticart avatar Aug 03 '16 01:08 semanticart

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 avatar Aug 04 '16 20:08 radenling

@radenling could you try this patch? https://github.com/neovim/neovim/issues/3030#issuecomment-233194402

justinmk avatar Aug 04 '16 22:08 justinmk

@justinmk that patch didn't make a difference for me.

radenling avatar Aug 05 '16 06:08 radenling

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.

radenling avatar Aug 06 '16 12:08 radenling

One way of reproducing this issue I've found is using ack.vim with dispatch support enabled.

tpict avatar May 02 '17 15:05 tpict

Fix (at least for the first problem) will land in 0.2.1: https://github.com/neovim/neovim/pull/6595

justinmk avatar May 02 '17 16:05 justinmk