Skip to content

Commit 0f0f221

Browse files
committed
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.
1 parent bdbe43e commit 0f0f221

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/strategies/completion.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ _zsh_autosuggest_strategy_completion() {
122122
# versions of zsh (older than 5.3), we sometimes get extra bytes after
123123
# the second null byte, so trim those off the end.
124124
# See http://www.zsh.org/mla/workers/2015/msg03290.html
125-
suggestion="${${line#*$'\0'}%$'\0'*}"
125+
suggestion="${${(@0)line}[2]}"
126126
} always {
127127
# Destroy the pty
128128
zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME

zsh-autosuggestions.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ _zsh_autosuggest_strategy_completion() {
608608
# versions of zsh (older than 5.3), we sometimes get extra bytes after
609609
# the second null byte, so trim those off the end.
610610
# See http://www.zsh.org/mla/workers/2015/msg03290.html
611-
suggestion="${${line#*$'\0'}%$'\0'*}"
611+
suggestion="${${(@0)line}[2]}"
612612
} always {
613613
# Destroy the pty
614614
zpty -d $ZSH_AUTOSUGGEST_COMPLETIONS_PTY_NAME

0 commit comments

Comments
 (0)