From c04e015d13fdee2903af9740e46540fa7c9295c4 Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Wed, 17 Apr 2019 23:29:52 -0600 Subject: [PATCH] Add to explanation of extra stuff after `zpty -r` --- src/strategies/completion.zsh | 6 ++++-- zsh-autosuggestions.zsh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/strategies/completion.zsh b/src/strategies/completion.zsh index 246f0bd..8dc1f9d 100644 --- a/src/strategies/completion.zsh +++ b/src/strategies/completion.zsh @@ -108,8 +108,10 @@ _zsh_autosuggest_strategy_completion() { # content between the first two null bytes. zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0' - # On older versions of zsh, we sometimes get extra bytes after the - # second null byte, so trim those off the end + # Extract the suggestion from between the null bytes. On older + # versions of zsh (older than 5.3), we sometimes get extra bytes after + # the second null byte, so trim those off the end. + # See http://www.zsh.org/mla/workers/2015/msg03290.html suggestion="${${${(M)line:#*$'\0'*$'\0'*}#*$'\0'}%%$'\0'*}" } always { # Destroy the pty diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 753228e..cef55f8 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -590,8 +590,10 @@ _zsh_autosuggest_strategy_completion() { # content between the first two null bytes. zpty -r $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME line '*'$'\0''*'$'\0' - # On older versions of zsh, we sometimes get extra bytes after the - # second null byte, so trim those off the end + # Extract the suggestion from between the null bytes. On older + # versions of zsh (older than 5.3), we sometimes get extra bytes after + # the second null byte, so trim those off the end. + # See http://www.zsh.org/mla/workers/2015/msg03290.html suggestion="${${${(M)line:#*$'\0'*$'\0'*}#*$'\0'}%%$'\0'*}" } always { # Destroy the pty