Implement asynchronous suggestions #134

Closed
wants to merge 1 commit into
from

3 participants

@PythonNut

Hey, just throwing this out there. If you guys don't want to merge it, I'm totally okay with maintaining my own fork.

This is based on the fantastically splendid zsh-async library. Since I don't really know how dependency management works in ZSH, I just assume that the file has been sourced prior to this one.

I wrote this because I wanted autosuggestions on an old Raspberry Pi, but the three-hundred millisecond pauses were making typing unpleasant. Now the suggestions don't interfere with typing. :)

Unfortunately, I couldn't figure out how to pass the history array to the async job efficiently, so I have to resort to reading the $HISTFILE to get the history. This isn't terribly efficient, but it happens in the async job, so the perceived lag is not affected. However, it could lead to some subtle errors if [[ -o extended_history ]] doesn't reflect the current structure of the $HISTFILE (not a problem for me personally because I always have it on). If you have any idea how to improve this, please tell.

@tarruda

In the repository history there's a completion server which I used to try implementing async completion at the start of the project(not only for history, but it also used the user's custom completion which could be slow). I remember it didn't work properly because of zsh limitations at the time, but maybe you can reuse something there.

@PythonNut

@tarruda I did take a look at that a while ago, but I honestly couldn't tell what was going on. (I don't blame you, zsh is an especially baroque language; I even have trouble reading my own code from time to time.) I think it's interesting, and ultimately I would like to revisit the idea of suggesting completions. However, I do think that zsh-async allows for a cleaner, easier to understand implementation.

@ericfreese you seem to be running the show now. Does this interest you? If it does, I'll try to keep this synchronized and we can work on merging it, but if not, then I'll close it.

@PythonNut PythonNut referenced this pull request Mar 15, 2016
Open

Slow speed of cd #136

@ericfreese
zsh-users member
@PythonNut

This is the issue I mentioned.

I can't, for the life of me, seem to find a way to get the history into the async job. This hack works for me, but maybe I'm being dumb and there's a way to pass $history with minimal overhead.

@PythonNut

@ericfreese thanks. I look forward to your feedback.

@ericfreese
zsh-users member

@PythonNut

Thank you very much for the work and the PR, but I don't think I want to merge this because of the added dependency on the zsh-async project. I think we can come up with a more lightweight solution. It looks like zsh-async uses pseudoterminals via the zpty module. We could use zpty directly to implement the suggestion fetching. I've also been looking a bit into using a coproc, but there are a few kinks I still need to work through.

Making z-asug asynchronous is high priority on my list since I think it will fix many of the existing performance issues. I just don't think this PR is quite the right way to do it.

Thanks again and sorry for such a slow response!

@ericfreese ericfreese closed this Jun 6, 2016
@PythonNut

Hey, thanks for getting back to me. If you can use the extra information specific to this problem to create a more optimal solution, then that's great!

I only used zsh-async because it's easy, and I've had a lot of frustration with asynchronous tasks in zsh in the past.

I look forward to a superior solution.

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