zsh-autosuggestions: Highlight style is not cleared on accept when manually set to a value <8
Describe the bug
If ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE is manually set where fg or bg are less than 8, then the highlighting is not reset when accepting or partially accepting the suggestion.
To Reproduce
% zsh -df
% source path/to/zsh-autosuggestions.zsh
% ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=1'
% ZSH<right arrow key>
(instead of typing <right arrow key> press the right arrow key on your keyboard to accept the autosuggestion, which should be _AUTOSUGGEST_HIGHLIGHT_STYLE='fg=1' in red text).
At this point, ZSH should be in the regular color but _AUTOSUGGEST_HIGHLIGHT_STYLE='fg=1' (which was completed) will still be in red.
Note that similar results occur for fg=x or bg=x when x<8, or a combination thereof (fg=x,bg=y where either x or y are <8).
Expected behavior
The color of _AUTOSUGGEST_HIGHLIGHT_STYLE='fg=1' would be reset, like when the variable is unchanged or set to a value >=8.
Screenshots
Note how the cursor (yellow vertical bar) is ahead of the red text, so it has retained the color even though it was accepted.
Desktop
- OS + distribution: Arch Linux
- Zsh version: 5.9
- Plugin version: a411ef3e0992d4839f0732ebeb9823024afaaaa8
- Terminal: alacritty 0.11.0-dev (ed4614d0)
Additional context
If I remember correctly, this issue began when I updated to zsh 5.9. I’m not exactly sure whether it was that update, but I know I didn’t use to have this issue and started having it sort of recently (a few weeks or months ago).
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 12
- Comments: 17 (1 by maintainers)
Commits related to this issue
- 47510: drop code that avoided termcap for named colours The inconsistency caused test failures where TERM is e.g. rxvt-unicode. This also makes a couple of bits available in zattr by removing flags i... — committed to zsh-users/zsh by deleted user 3 years ago
- .zshrc: autosuggestions change color to blue This works around a bug in newer zsh https://github.com/zsh-users/zsh-autosuggestions/issues/698, and is just more visually appealing. — committed to Hi-Angel/dotfiles by Hi-Angel 2 years ago
- zsh-autosuggestions: Change color to fix bug wiht Zsh 5.9 This fixes the bug described at: https://github.com/zsh-users/zsh-autosuggestions/issues/698 — committed to adrienverge/dotfiles by adrienverge 2 years ago
- switched highlight style - back to the dark config to avoid this bug https://github.com/zsh-users/zsh-autosuggestions/issues/698 where it wasn't refreshed after accept — committed to totallyGreg/home by totallyGreg 4 months ago
ok, meanwhile I double-checked, and yes, 5.9 ignores the “memo=token”
It turned out, in my case, the problem was that I set my ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE to custom color code with CAPITAL case hexadecimal values (#A1A2A6) and seems the
region_highlightarray handling (now?) converts to lower case everything that added to it, therefore the_zsh_autosuggest_highlight_reset()function could not remove the earlier set value via the usedregion_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT_SAVE}")expressionso, take care, either
_zsh_autosuggest_highlight_applywith this tiny modification in zsh-autosuggestions.zshSame problem on Gentoo Linux, ZSH version
5.9.Only workaround for now for me was to change foreground color id to more than
8;14looked similar enough to6😃I don’t use
zsh-syntax-highlightingand have this issue too, but not whenZSH_AUTOSUGGEST_HIGHLIGHT_STYLEis set toboldorunderline. Settingfgorbgwith any other option prevents the style from clearing.I guess bisecting zsh might be required?