mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
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.
This commit is contained in:
parent
c3d4e576c9
commit
5b378b988a
2 changed files with 6 additions and 2 deletions
|
@ -8,7 +8,9 @@ _zsh_autosuggest_highlight_reset() {
|
||||||
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
||||||
|
|
||||||
if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then
|
if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then
|
||||||
region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}")
|
if (( $#region_highlight )); then
|
||||||
|
shift -p region_highlight
|
||||||
|
fi
|
||||||
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,9 @@ _zsh_autosuggest_highlight_reset() {
|
||||||
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
||||||
|
|
||||||
if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then
|
if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then
|
||||||
region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}")
|
if (( $#region_highlight )); then
|
||||||
|
shift -p region_highlight
|
||||||
|
fi
|
||||||
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue