Skip to content

Fix colors not being reset on (partial) accept w/ recent ZSH (fixes #789) #790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ElementW
Copy link

@ElementW ElementW commented May 22, 2024

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.

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.
@tomasnorre
Copy link

I can confirm that this fix solves the problem I have in #789

@ErwanGarreau
Copy link

I had the exact same problem (the zsh-autosuggestions proposed color was not changing back although it was accepted).
This commit also fixed it for me. Thank you !

@rylwin
Copy link

rylwin commented Dec 29, 2024

This commit also fixes it for me, too. I started experiencing this issue after upgrading to Ubuntu 24.04 (from 22.04)

$  zsh --version
zsh 5.9 (x86_64-ubuntu-linux-gnu)

@dolphin-cat
Copy link

also fixes it for me, #820

@enoryw
Copy link

enoryw commented Mar 24, 2025

What's preventing this from getting merged?

@rieje
Copy link

rieje commented Apr 3, 2025

Fixed for me too. Can this be merged? It's nearly a year and colors being broken for an autosuggestion plugin that relies on colors is kind of essential...

@rbjorklin
Copy link

I was having the same problem until I started using the code from this PR.

@ericfreese any chance you have a moment to review and merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coloring doesn't change on auto suggestions
8 participants