-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
A possibly needed workaround for <( ) process substitution #364
Comments
Thanks for this! I was actually having issues with Ctrl-C on develop but wasn't sure exactly why and hadn't yet put in the effort to figure out what was going on. I'm busy for the next few weeks but I'll take a closer look at this before cutting a release from develop. |
@psprint Did you ever figure out why exactly this was necessary? I'm really curious what's going on that makes ctrl-c stop working. |
I've found something interesting that you may have also found. At least in my case, it seems the problem only occurs with the |
Interesting. I was tracking this for many days and when workaround appeared I was too tired to continue, so I dont know why this problem occurs |
Fair enough. I'll see what I can find... |
@psprint I've submitted a patch that fixes this issue upstream |
See technique used in `fast-syntax-highlighting`: - zdharma/fast-syntax-highlighting@ca2e18b - https://www.zsh.org/mla/users/2018/msg00424.html Also see https://www.zsh.org/mla/users/2018/msg00432.html In async response handler: - We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL or select error. - We always want to remove the handler, so it doesn't get called in an infinite loop when error is nval or err. There is an upstream bug that prevents ctrl-c from resetting the prompt immediately after a suggestion has been fetched asynchronously. A patch has been submitted, but a workaround for now is to add `command true` after the exec. See #364
See technique used in `fast-syntax-highlighting`: - zdharma/fast-syntax-highlighting@ca2e18b - https://www.zsh.org/mla/users/2018/msg00424.html Also see https://www.zsh.org/mla/users/2018/msg00432.html In async response handler: - We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL or select error. - We always want to remove the handler, so it doesn't get called in an infinite loop when error is nval or err. There is an upstream bug that prevents ctrl-c from resetting the prompt immediately after a suggestion has been fetched asynchronously. A patch has been submitted, but a workaround for now is to add `command true` after the exec. See #364
See technique used in `fast-syntax-highlighting`: - zdharma/fast-syntax-highlighting@ca2e18b - https://www.zsh.org/mla/users/2018/msg00424.html Also see https://www.zsh.org/mla/users/2018/msg00432.html In async response handler: - We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL or select error. - We always want to remove the handler, so it doesn't get called in an infinite loop when error is nval or err. There is an upstream bug that prevents ctrl-c from resetting the prompt immediately after a suggestion has been fetched asynchronously. A patch has been submitted, but a workaround for now is to add `command true` after the exec. See #364
See technique used in `fast-syntax-highlighting`: - zdharma/fast-syntax-highlighting@ca2e18b - https://www.zsh.org/mla/users/2018/msg00424.html Also see https://www.zsh.org/mla/users/2018/msg00432.html In async response handler: - We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL or select error. - We always want to remove the handler, so it doesn't get called in an infinite loop when error is nval or err. There is an upstream bug that prevents ctrl-c from resetting the prompt immediately after a suggestion has been fetched asynchronously. A patch has been submitted, but a workaround for now is to add `command true` after the exec. See #364
FYI @psprint it looks like this workaround doesn't work for zsh versions older than 5.0.8. |
See technique used in `fast-syntax-highlighting`: - zdharma/fast-syntax-highlighting@ca2e18b - https://www.zsh.org/mla/users/2018/msg00424.html Also see https://www.zsh.org/mla/users/2018/msg00432.html In async response handler: - We only want to read data in case of POLLIN or POLLHUP. Not POLLNVAL or select error. - We always want to remove the handler, so it doesn't get called in an infinite loop when error is nval or err. There is an upstream bug that prevents ctrl-c from resetting the prompt immediately after a suggestion has been fetched asynchronously. A patch has been submitted, but a workaround for now is to add `command true` after the exec. See #364
Closing this. I've added the workaround with PR #417 |
Great job!
Wt., 9.04.2019, 20:36 użytkownik Eric Freese <[email protected]>
napisał:
… @psprint <https://github.com/psprint> I've submitted a patch that fixes
this issue upstream
https://www.zsh.org/mla/workers/2019/msg00252.html
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#364 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFxOCIlUus63CaFRz0WMWCxdWyLv9AjFks5vfN2bgaJpZM4VyxCm>
.
|
Can we use
BTW, Thank you very much for your great work. |
Probably not, given that the comment just above that line of code says a fork is needed, and zsh-autosuggestions/src/async.zsh Lines 45 to 47 in ae315de
Your setup violates POSIX (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tag_17_06) and therefore is likely to break other upstreams too:
(I'm not a z-asug developer.) |
@danielshahaf Thank you for the reply!
Not sure if it violates,
I'm not sure how this workaround works, but maybe something like I get a lot of |
There is a test for this workaround here zsh-autosuggestions/spec/async_spec.rb Line 53 in ae315de
If you can get the tests running, you can try some alternatives to The upstream bug has also been fixed in more recent versions of zsh so at this point we may be able to only run the |
The quoted sentence refers to the execvp(3) C function, not to the Incidentally, zsh's
I recommend to install in the build environment whichever package provides a
https://zsh.org/workers/44214 is zsh commit |
---
Sorry for the long response, I've set up a testing environment, made a
fix and checked it on versions 5.6.2 and 5.8. Tests are passed.
src/async.zsh | 3 ++-
zsh-autosuggestions.zsh | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/async.zsh b/src/async.zsh
index 4314e8c..218eb26 100644
--- a/src/async.zsh
+++ b/src/async.zsh
@@ -44,7 +44,8 @@ _zsh_autosuggest_async_request() {
# There's a weird bug here where ^C stops working unless we force a fork
# See #364
- command true
+ autoload -Uz is-at-least
+ is-at-least 5.8 || command true
# Read the pid from the child process
read _ZSH_AUTOSUGGEST_CHILD_PID <&$_ZSH_AUTOSUGGEST_ASYNC_FD
diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh
index a8ef6c4..7ebc490 100644
--- a/zsh-autosuggestions.zsh
+++ b/zsh-autosuggestions.zsh
@@ -804,7 +804,8 @@ _zsh_autosuggest_async_request() {
# There's a weird bug here where ^C stops working unless we force a fork
# See #364
- command true
+ autoload -Uz is-at-least
+ is-at-least 5.8 || command true
# Read the pid from the child process
read _ZSH_AUTOSUGGEST_CHILD_PID <&$_ZSH_AUTOSUGGEST_ASYNC_FD
--
2.31.1
|
Dear maintainers, is it possible to apply this patch?
Seems like a reasonable solution to me.
|
Hi, thanks for the patch! Yeah, we should be able to apply this. I'm sorry I haven't had much time for this project lately but should be able to get this in soon. I've also been meaning to cut a new release for some time. Can you send a pull request to |
Sure!
|
Hello,
in branch
develop
there's currently use of<( ... )
process substitution to do asynchronous calls:zsh-autosuggestions/zsh-autosuggestions.zsh
Lines 717 to 725 in 681ffc7
I use the same technique in fast-syntax-highlighting, however, I add
command sleep 0
(could make itcommand true
) after theexec
: https://github.com/zdharma/fast-syntax-highlighting/blob/e06288a617b12e8038fdf5bc4bd40b6a25ef5332/fast-highlight#L917-L918The reason for this additional call are severe problems with Ctrl-C that occur when using
{MYFD}<
construct, as my investigation showed.So in this issue I just want to mention that in case of any Ctrl-C problems,
command true
after exec should help.The text was updated successfully, but these errors were encountered: