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

Make scanning non-blocking (ie. async) #421

Open
idr4n opened this issue Apr 3, 2024 · 2 comments
Open

Make scanning non-blocking (ie. async) #421

idr4n opened this issue Apr 3, 2024 · 2 comments

Comments

@idr4n
Copy link

idr4n commented Apr 3, 2024

Hi,
I just started trying the plugin and although I really like how fast it find matches in normal size projects, when using these two commands at least (CommandT and CommandTFind) in the whole $HOME directory, it hangs for way too long until it opens up the window and show the results, blocking the whole neovim instance in the meantime.

Although it is not the case that I want to search my whole home directory, it sometimes happens (normally by mistake) that I don't realize I open neovim in the home directory and start searching for files. As point of comparison, Fzf.vim and FzfLua handle this very nicely and it doesn't block and I can cancel and quit right away, even I can search and it will start showing some results right away. Telescope on the other hand does stop scanning for files if I start searching but at least I can just close telescope and quit or do something else. CommandT, however, just block the neovim instance completely and I cannot stop the process or quit neovim (unless killing the tmux pane or closing the terminal).

It would be nice if CommandT handles very large directories in a similar way as Fzf that while it keeps scanning for files, I can still use the interface to some extend and even start searching and getting some results.

Not sure if this is something that can be achieve, but I just wanted to mention it nonetheless.

Gracias de antemano!

@wincent
Copy link
Owner

wincent commented Apr 3, 2024

So, for now, the best way to mitigate this kind of thing is to set max_files as described in the docs. (This is assuming you're using the Lua implementation.)

I agree that it would be nice to be fully async, so I'm going to retitle this and think about it. The main problem with going async is that it may add overhead, so that is why I haven't done it in all these years, instead preferring to make the scanning as fast as possible to try and mitigate the downsides of doing the scanning in single-threaded mode. Note also that some of the alternative scanners might be faster than the default one, like the Ripgrep scanner, or the Git-based scanner, or the Watchman-based scanner etc. Those are mentioned in the docs too.

@wincent wincent changed the title CommandT hangs for too long Make scanning non-blocking (ie. async) Apr 3, 2024
@idr4n
Copy link
Author

idr4n commented Apr 3, 2024

Hi Greg,
Thanks for suggesting that! Actually the max_files option does work for me and solve the primary issue of by mistake scanning very large directories and having the UI blocked. I added the suggested 100,000, and it takes maybe only two to three seconds for opening for me which is good in this case.

Since your suggestion solves the issue for me, feel free to close this or keep it open while considering to add the async if there are no downsides to it, as you wish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants