From 0f0f221180b1fec3254e74d8d657c3a929870b1b Mon Sep 17 00:00:00 2001 From: Eric Freese Date: Wed, 25 Sep 2019 15:36:07 -0600 Subject: [PATCH] cleanup: Split on null bytes instead of pattern matching Follow-up to technique tried in commit d94475c after I learned about the `@` flag to keep empty strings in the array. --- src/strategies/completion.zsh | 2 +- zsh-autosuggestions.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/strategies/completion.zsh b/src/strategies/completion.zsh index dfbf6eb..646f106 100644 --- a/src/strategies/completion.zsh +++ b/src/strategies/completion.zsh @@ -122,7 +122,7 @@ _zsh_autosuggest_strategy_completion() { # 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="${${line#*$'\0'}%$'\0'*}" + suggestion="${${(@0)line}[2]}" } always { # Destroy the pty zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME diff --git a/zsh-autosuggestions.zsh b/zsh-autosuggestions.zsh index 950cf5b..66eae6f 100644 --- a/zsh-autosuggestions.zsh +++ b/zsh-autosuggestions.zsh @@ -608,7 +608,7 @@ _zsh_autosuggest_strategy_completion() { # 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="${${line#*$'\0'}%$'\0'*}" + suggestion="${${(@0)line}[2]}" } always { # Destroy the pty zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME