From 625cca3a8e5a14647158aa3f3634350e18ff5d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9leste=20Wouters?= Date: Wed, 22 May 2024 11:23:55 +0200 Subject: [PATCH] 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. --- src/highlight.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/highlight.zsh b/src/highlight.zsh index 273c03d5..bae52e5c 100644 --- a/src/highlight.zsh +++ b/src/highlight.zsh @@ -8,7 +8,7 @@ _zsh_autosuggest_highlight_reset() { typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT if [[ -n "$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT" ]]; then - region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}") + shift -p region_highlight unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT fi }