zsh-users / zsh-syntax-highlighting

Fish shell like syntax highlighting for Zsh.
github.com/zsh-users/zsh-syntax-highlighting
BSD 3-Clause "New" or "Revised" License
20.29k stars 1.33k forks source link

Using with Zinit "Turbo mode" breaks zsh autosuggestions #742

Open 3v1n0 opened 4 years ago

3v1n0 commented 4 years ago

I've basically the same issue as the one reported here for the fast highlighter: https://www.reddit.com/r/zsh/comments/f7w14o/strange_bug_with_p10k_zshautosuggestions_fsyh/

You can watch it here: https://asciinema.org/a/0D0aVmCbw9jrVff0L7XAm9JH9

When not using the turbo-mode this is fixed, but per se, the turbo mode doesn't do much other than initializing the plugins with a delay. So it should not affect this.

A similar issue has been fixed in the fast plugin as well, so I assume that this is the right place to report.

danielshahaf commented 4 years ago

Could you please show the output of typeset -p ZSH_VERSION ZSH_PATCHLEVEL ZSH_HIGHLIGHT_REVISION ZSH_HIGHLIGHT_VERSION? Also the same information for zsh-autosuggesions and for zinit.

Please post minimal reproduction instructions that start by running zsh -f and reproduce the problem.

A similar issue has been fixed in the fast plugin as well, so I assume that this is the right place to report.

Link to that issue and/or commit, please?

3v1n0 commented 4 years ago

Could you please show the output of typeset -p ZSH_VERSION ZSH_PATCHLEVEL ZSH_HIGHLIGHT_REVISION ZSH_HIGHLIGHT_VERSION

typeset ZSH_VERSION=5.4.2 # But I see the same in ZSH 5.8
typeset ZSH_PATCHLEVEL=ubuntu/5.4.2-3ubuntu3.1 # sam in 5.8-3ubuntu1
typeset ZSH_HIGHLIGHT_REVISION=HEAD
typeset ZSH_HIGHLIGHT_VERSION=0.7.2-dev

I'm using zsh-autosuggestion and zinit from current master.

So, I've tried to reproduce re-creating my way-more complex rc file, however splitting it down, it looks like that the problem doesn't happen until I load powerlevel10k.

You can see: it in this gist: https://gist.github.com/3v1n0/63bdec4d9c69cd6c4a483351070bfcdb#file-zinitrc-L50

I load it as env ZDOTDIR=/tmp/TEST_ZDO zsh given it gonna install things all relative to $ZDOTDIR.

The issue is quite visible by using the forward word char (in my case also Alt+l).

Basically powerleve10k needs to be loaded normally, not in turbo-mode (i.e. using wait), and in such case the various components don't work (note that also the zsh-history-substring-search highlighting is broken - activated via Alt+j or Alt+k).


However, while powerlevel10k might be somewhat related to this issue (as said, without it there's no such bug), I'm still convinced that the problem is due to this plugin (zsh-syntax-highlighting) because both

Both the autosuggestion color and the substring search colors are working properly.

Link to that issue and/or commit, please?

Not totally sure about, but it was mentioned in the reddit comments, so it could be

danielshahaf commented 4 years ago

Wow. Thanks for the analysis and pointers, but I'm afraid you'll have to narrow it down further. I just don't have the brainwidth to figure out a bug that only happens when you use an optional feature of a third-party framework to use a fourth-party plugin.

And if that's not big enough a can of worms as it is, the commits you mention are widget-wrapping stuff, for which I'd normally recommend using the feature/redrawhook branch…but that branch has an interoperability issue with zsh-autosuggestions, which is likely going to have to be fixed by patching zsh itself (see https://github.com/zsh-users/zsh-syntax-highlighting/issues/579, https://github.com/zsh-users/zsh-autosuggestions/issues/529, https://github.com/zsh-users/zsh/pull/57).

Anyway, I guess you have two possible approaches:

  1. See if rebuilding zsh with that PR and using the feature/redrawhook branch of zsh work around the problem (even though we don't know what the problem is, yet).
  2. Work with Roman and Sebastian to get an operable description of what zinit wait powerlevel10k does differently to zinit powerlevel10k.

However, while powerlevel10k might be somewhat related to this issue (as said, without it there's no such bug), I'm still convinced that the problem is due to this plugin (zsh-syntax-highlighting) because both

* disabling it

* Replacing it with `zdharma/fast-syntax-highlighting`

You didn't finish the sentence, but in any case, the conclusion doesn't follow from the premises. The problem might be in z-sy-h, but it's also possible that z-sy-h is correct and one of the other involved plugins is making an invalid assumption.


By the way, the video you linked doesn't use z-sy-h.

3v1n0 commented 4 years ago

Will look into this, but yes the video was using z-sy-h.

Also, my sentence was ending with "... disabling or replacing it" fixes the problem, and it's visible by the fact that zsh-users/zsh-history-substring-search works again.

danielshahaf commented 4 years ago

No, it wasn't. z-sy-h will never highlight the two characters comprising the $( token differently to each other, as the video does.