-
-
Notifications
You must be signed in to change notification settings - Fork 846
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
async pickers take 3 #691
async pickers take 3 #691
Conversation
I think I'm missing something here..
|
Make sure that you are using the latest version of my plenary pr because I added the channels today |
yup, the commit is |
hmm I'm not sure what is happening here |
oh I forgot to commit my local repo. |
ok nice, it works :) edit: it might look like it's just debouncing, but it's not. If the directory is too big (at least on my machine), it looks like this, but if it's small enough like Neovim repo, the visual representation acts normally, it's just faster and not blocking the input. stuff.mp4 |
skip-checks: true
please use tjs version #709 |
TY :) thjis made it super easy to implement u r the bomb ober <3 |
note: this is only implemented for oneshot jobfinders. If you want to test this, use
find_files
on your home directory.note2: this requires the async await pr
implementation
nvim_buf_attach
First we use channels to get the
buf_lines_event
. Using channels means that we can set the polling rate which I have set to 50ms. This means that we poll for abuf_lines_event
every 50ms, and only get the last event. What this means is that if multiple events occur within 50ms, we throw them out and ignore them. This is good because this makes it so that we don't sort unnecesarily and this also means that we are always soring the latest event.non blocking sorting
Sorting entries in a regular loop will completely block the editor. We sort in an
idle
loop instead to put each sort on onelibuv
event loop iteration.canceling
Because we used an
idle
, cancelling is very easy. When the user types before the previous sort has been completed, we cancel the previous sort. This is done by using a oneshot channel. In the telescope main loop if the user typed before the previous sort completed, we will send a signal to cancel the previous sort. This makes everything smooth and further makes sure that we are only sorting the latest event.displaying the entries
Previously, we display every entry while it is sorted. For synchronous finding, this is okay. However, we are doing everything in an
idle
loop, so this will cause extreme flickering and highlighting issues. This was the 'weird' sorting animation that @elianiva was seeing. Now this is completely fixed because when we process an entry, we do not immediately display it, we only display all the entries when we are finished with processing everything. This is also whatfzf
does. One thing that we could do is add a percentage indicator which shows how far through processing we are. This is again fromfzf
.the future
This will be very easy to implement for other finders, I just don't have enough time yet. The only finder that we cannot directly apply this to is
grep_string
. The reason is that there are so many entries that it completely overloads thejobs
that we currently have. The solution is the new jobs pr. Once we have those we can again apply this implementation. If you want to see the speed difference, run the benchmark in the pr, it will testrg
.small issues
The only issue with this is that it doesn't highlight the current line correctly. This is likely due to the fact that we are only calling display code when we are done filtering everything. We need to separate display code from the other code so we can call the highlighting stuff separate from the other stuff. Another issue is that it doesn't display the first entry correctly. This is also the same issue. To see the correct entry just move your cursor back and forth.