Skip to content

Commit 625cca3

Browse files
committed
Fix colors not being reset on accept w/ recent ZSH (fixes #789)
The ZSH manual describes `region_highlight` as being an array in https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting, therefore the previous strategy of removing as many characters as the last suggestion is *not* the way to do it, explaining why it broke on recent ZSH versions. Replace this logic with a simple last-element delete. Keeps the `_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT` variable intact since there's no downside in tracking its content, as it still used as a marker for whether a suggestion highlight was applied.
1 parent c3d4e57 commit 625cca3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/highlight.zsh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _zsh_autosuggest_highlight_reset() {
88
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
99

1010
if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then
11-
region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}")
11+
shift -p region_highlight
1212
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
1313
fi
1414
}

0 commit comments

Comments
 (0)