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

UI blocks until all results are collected #38

Open
mizlan opened this issue Jun 8, 2023 · 3 comments
Open

UI blocks until all results are collected #38

mizlan opened this issue Jun 8, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@mizlan
Copy link

mizlan commented Jun 8, 2023

Would there be a way to incrementally display results? Currently if ran with rg --files | zf in home directory, there is a few seconds blocking until the prompt displays. I don't think it would be trivial to make it work but I am curious.

@natecraddock
Copy link
Owner

Hi @mizlan!

This is something I have thought about from time to time. My personal use case for zf is usually within the scope of a single project, so I rarely have over 10,000 files to read into zf. This means I haven't given much thought to a incremental display.

As you have observed, the current zf implementation is blocking. All of stdin is read into a buffer which is then split on lines. Those lines are then given to the UI code. The UI only runs the filtering on keypresses. So that's why you are seeing the current behavior.

But I am planning on adding a UI preview feature sometime soon (once the next Zig version is released): #25. It seems like the next version will be the end of the month.

That feature will require me to rework the event loop to be more async. As part of that, I think it would not be difficult to read from stdin in batches to make the UI immediately available.

Another side to this is multithreading the filtering of zf. For large batches of input lines, the other issue would be making sure the filtering is very fast.

Feel free to let me know your thoughts on that!

@mizlan
Copy link
Author

mizlan commented Jun 8, 2023

My personal use case for zf is usually within the scope of a single project, so I rarely have over 10,000 files to read into zf

Same! I was just curious I guess, it isn't a real problem for me almost ever in practice.

Another side to this is multithreading the filtering of zf. For large batches of input lines, the other issue would be making sure the filtering is very fast.

I think multithreading would be very very cool and interesting to see! Though I am interested in the Zig language, I am not super experienced in writing multithreaded programs, so I'm afraid I can't contribute too much, but I will be excitedly watching for updates to zf :)

@natecraddock
Copy link
Owner

Same! I was just curious I guess, it isn't a real problem for me almost ever in practice.

In that case I'll keep this issue open, but wait and see if there is someone with that use case. I am open to it right now, but I don't want to implement it if I don't need to.

I think multithreading would be very very cool and interesting to see! Though I am interested in the Zig language, I am not super experienced in writing multithreaded programs, so I'm afraid I can't contribute too much, but I will be excitedly watching for updates to zf :)

I'll probably get to this in the next few weeks if everything goes according to plan :)

@natecraddock natecraddock added the enhancement New feature or request label Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants