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

fix: no stop reading on spawn #227

Merged
merged 1 commit into from
Oct 3, 2023
Merged

Conversation

linrongbin16
Copy link
Owner

No description provided.

@codecov
Copy link

codecov bot commented Oct 3, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Files Coverage Δ
lua/fzfx/utils.lua 80.24% <85.71%> (-0.60%) ⬇️

📢 Thoughts on this report? Let us know!.

@linrongbin16
Copy link
Owner Author

linrongbin16 commented Oct 3, 2023

I have noticed this issue for quite a long time, it really took me quite some effort to make it correct.

In neovim and luv github repo, I had submitted a lot of questions about how to correctly handle the output of uv.spawn API, but finally I made it correct!!

In this issue: luvit/luv#677, I submit the demo video that re-produce this issue (on Windows 10 x86_64):

2_5.C__WINDOWS_system32_cmd.exe.2023-10-03.07-10-25.mp4

Notice the lines count on the top-right corner of the left side of fzf:

  1. 78 (restricted mode)
  2. 1550 (press CTRL-U to unrestricted mode)
  3. 78 (press CTRL-R to go back to restricted)
  4. 1388 (press CTRL-U again to unrestricted)

We can see the results of finding files is inconsistent during each executing!!!

I realized there should be some data loss during running the fd command, and I believe the data loss is coming from that uv.spawn stop processing the data read from stdout.

Finally anyway, this PR fix it, I had tried a lot of things:

  • only call vim.loop.stop after all 3 of out_pipe, err_pipe and process_handle closed.
  • check if data_buffer still contains any data not been processed.
  • etc

But none of them work, finally in this PR, I removed the out_pipe:read_stop() and err_pipe:read_stop(), and it works!!!

See this demo (fixed by this PR):

2_3.pwsh.in.fzfx.nvim.2023-10-03.22-38-01.mp4

You can see the unrestricted lines count is always 1719!!!

@linrongbin16 linrongbin16 merged commit daf2731 into main Oct 3, 2023
7 checks passed
@linrongbin16 linrongbin16 deleted the linrongbin16/fix-stop-read branch October 3, 2023 14:39
This was referenced Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant