Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: emulate bash key bindings

On Fri, Jan 10, 2020 at 6:06 PM Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> [sorry for the late answer]

No worries. Thanks for replying.

Let me try to describe what's going on. I've only skimmed through the
implementations of these plugins, so please take it with a grain of

When zsh-syntax-highlighting is used together with
zsh-autosuggestions, everything works correctly as long as every
widget in which zsh-syntax-highlighting applies its highlighting is
wrapped by zsh-autosuggestions. This is necessary because
zsh-syntax-highlighting removes highlighting from POSTDISPLAY. There
are two situations where the combination of zsh-syntax-highlighting
and zsh-autosuggestions results in missing POSTDISPLAY highlighting:

1. zsh-syntax-highlighting is applying highlighting in a widget that
zsh-autosuggestions does not wrap.
2. zsh-syntax-highlighting has wrapped a widget *after*
zsh-autosuggestions wrapped it.

happens because of (1). Specifically, zsh-syntax-highlighting is
applying highlighting in zle-line-pre-redraw, which
zsh-autosuggestions doesn't wrap. zsh-autosuggestions doesn't wrap
widgets whose names match patterns from
ZSH_AUTOSUGGEST_IGNORE_WIDGETS. The default value of this parameter
includes pattern `zle-*`.

In order to use zsh-autosuggestions together with feature/redrawhook
branch of zsh-syntax-highlighting users need to override
ZSH_AUTOSUGGEST_IGNORE_WIDGETS so that it does not contain a pattern
against which `zle-line-pre-redraw` can match.

This may be a viable course of action even though it'll likely have
very high cost for the users of these plugins. If I may make a
suggestion, perhaps zsh-syntax-highlighting shouldn't remove
highlighting from POSTDISPLAY? zsh-autosuggestions owns POSTDISPLAY
area while zsh-syntax-highlighting owns BUFFER. zsh-autosuggestions
doesn't touch highlighting of BUFFER, which allows it to peacefully
coexist with syntax highlighting plugins. If zsh-syntax-highlighting
did the same w.r.t. POSTDISPLAY highlighting, there would be no
widget-wrapping-order dependencies and feature/redrawhook wouldn't
introduce breaking changes for users who rely on both of these great

Just my 2 cents. I hope it makes at least some sense.


Messages sorted by: Reverse Date, Date, Thread, Author