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
19.55k stars 1.32k forks source link

Highlighting bug after updating to zsh 5.8.1 #857

Closed jnooree closed 2 years ago

jnooree commented 2 years ago

I've found a highlighting bug when this plugin is used in combination with zsh-autosuggestions.

When zsh autosuggestion suggests an autocompletion in the first place, the text is colored in "gray" (i.e., differently from the user-provided text). Before zsh 5.8.1, the color was preserved through syntax highlighting.

After updating, it is now colored as "black" (same as the text user has provided). I've confirmed that the text is still colored in gray when this plugin is not loaded. It might be an upstream bug; however, 5.8.1 does not introduce many changes, so this is not likely to be the case.

System Information

danielshahaf commented 2 years ago
diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh
index 2b42910..2502df0 100644
--- a/zsh-syntax-highlighting.zsh
+++ b/zsh-syntax-highlighting.zsh
@@ -166 +166 @@ _zsh_highlight()
-        if is-at-least 5.8.0.3 $ZSH_VERSION.0.0; then
+        if is-at-least 5.9.0.0 $ZSH_VERSION.0.0; then
@@ -418 +418 @@ _zsh_highlight_call_widget()
-if is-at-least 5.8.0.2 $ZSH_VERSION.0.0 && _zsh_highlight__function_callable_p add-zle-hook-widget
+if is-at-least 5.9.0.0 $ZSH_VERSION.0.0 && _zsh_highlight__function_callable_p add-zle-hook-widget
danielshahaf commented 2 years ago

Does the above patch fix the problem? (Excuse multiple emails)

patrick96 commented 2 years ago

This patch seems to fix the problem for me so far :)

hbarcelos commented 2 years ago

Sorry to reopen this, but I've applied the suggested path and still didn't manage to get it working properly:

asciicast

Here is some additional info:

➜ typeset -p ZSH_VERSION ZSH_PATCHLEVEL ZSH_HIGHLIGHT_REVISION ZSH_HIGHLIGHT_VERSION
typeset ZSH_VERSION=5.8.1
typeset ZSH_PATCHLEVEL=zsh-5.8.1-0-g1a490c7
typeset ZSH_HIGHLIGHT_REVISION=HEAD
typeset ZSH_HIGHLIGHT_VERSION=0.8.0-alpha2-dev

In my .zshrc I have:

  zplug "zsh-users/zsh-autosuggestions"

  zplug "zsh-users/zsh-syntax-highlighting", defer:2
danielshahaf commented 2 years ago

Did you restart zsh after applying the patch?

The patch has been committed (with a tweak); can you apply to latest unpatched master and see if it works then?

hbarcelos commented 2 years ago

Yes, I did restart zsh after applying the patch.

Which version should I apply the patch against?

* c5ce001 - (HEAD -> master, origin/master, origin/HEAD) main: Deconfuse $EDITOR (3 weeks ago) <Daniel Shahaf>
* 5459ebc - main: precommand_options += grc (3 weeks ago) <Daniel Shahaf>
* 2cd73fc - *: Update sourceforge links (3 weeks ago) <Daniel Shahaf>
* 643717c - changelog: Update zsh version numbers (3 weeks ago) <Daniel Shahaf>
* caeca0b - docs: regexp: Document the platform dependency (3 weeks ago) <Nuri Jung>
* 56b4433 - CI += zsh 5.8.1 (4 weeks ago) <Daniel Shahaf>
* 0ddb1a8 - driver: Bump the in-development is-at-least checks so they return false on zsh 5.8.1, released yesterday. (4 weeks ago) <Daniel Shahaf>
* c10808a - main: New test for issue #854 (6 weeks ago) <Daniel Shahaf>

The one from OP is the one at the bottom, should I try with that one?

danielshahaf commented 2 years ago

Which version should I apply the patch against?

Use c5ce001 without any patch.

* c5ce001 - (HEAD -> master, origin/master, origin/HEAD) main: Deconfuse $EDITOR (3 weeks ago) <Daniel Shahaf>
* 5459ebc - main: precommand_options += grc (3 weeks ago) <Daniel Shahaf>
* 2cd73fc - *: Update sourceforge links (3 weeks ago) <Daniel Shahaf>
* 643717c - changelog: Update zsh version numbers (3 weeks ago) <Daniel Shahaf>
* caeca0b - docs: regexp: Document the platform dependency (3 weeks ago) <Nuri Jung>
* 56b4433 - CI += zsh 5.8.1 (4 weeks ago) <Daniel Shahaf>
* 0ddb1a8 - driver: Bump the in-development is-at-least checks so they return false on zsh 5.8.1, released yesterday. (4 weeks ago) <Daniel Shahaf>
* c10808a - main: New test for issue #854 (6 weeks ago) <Daniel Shahaf>
hbarcelos commented 2 years ago

Not working :/. Same behavior as above.

I have this:

  zplug "zsh-users/zsh-autosuggestions"
  zplug "zsh-users/zsh-syntax-highlighting", defer:2

If I remove the defer part:

  zplug "zsh-users/zsh-autosuggestions"
  zplug "zsh-users/zsh-syntax-highlighting"

I get something a little better, but it still looks off:

asciicast

danielshahaf commented 2 years ago

Did it work for you before today? Did you just upgrade to 5.8.1 today?

Please take zplug out of the equation; try in 'zsh -f' and interactively run 'source /path/to/zsh-autosuggestions.zsh' and 'source /path/to/zsh-syntax-highlighting.zsh'.

I don't see anything wrong in the highlighting of the suggestion in the video. What did you expect to see?

For the various minor errors in the new video («exec» not being green at all times, «$SHELL» changing colour when the command was run) please open separate tickets with exact reproduction instructions for each. And please minimize those instructions; some of them might not require zsh-autosuggestions.

Thanks!

Not working :/

I have this:

  zplug "zsh-users/zsh-autosuggestions"
  zplug "zsh-users/zsh-syntax-highlighting", defer:2

If I remove the defer part:

  zplug "zsh-users/zsh-autosuggestions"
  zplug "zsh-users/zsh-syntax-highlighting"

I get something a little better, but it still looks off:

asciicast

-- Reply to this email directly or view it on GitHub: https://github.com/zsh-users/zsh-syntax-highlighting/issues/857#issuecomment-1068480489 You are receiving this because you commented.

Message ID: @.***>

hbarcelos commented 2 years ago

Did it work for you before today? Did you just upgrade to 5.8.1 today?

No, it has not been working for a while, not entirely sure for how long.

I don't see anything wrong in the highlighting of the suggestion in the video. What did you expect to see?

I'd expect zsh to become green before I press space.

Please take zplug out of the equation; try in 'zsh -f' and interactively run 'source /path/to/zsh-autosuggestions.zsh' and 'source /path/to/zsh-syntax-highlighting.zsh'.

Well, this must be it then... 🤔. If I don't use zplug, it works as expected:

  1. When typing I see zsh becoming green before I press space.
  2. The color is not updated as I type.

I'm gonna fiddle around with defer:<N> for both zsh-autosuggestions and zsh-syntax-highlighting to see if I can make it work properly.

For the various minor errors in the new video («exec» not being green at all times, «$SHELL» changing colour when the command was run) please open separate tickets with exact reproduction instructions for each. And please minimize those instructions; some of them might not require zsh-autosuggestions.

Thanks a lot... will do that.

danielshahaf commented 2 years ago

Did it work for you before today? Did you just upgrade to 5.8.1 today?

No, it has not been working for a while, not entirely sure for how long.

So, to be clear, you saw the bug under 5.8.0 too, right? If so, please continue on a new ticket, since this ticket is specifically about an issue that affected 5.8.1 but not 5.8.0.

I don't see anything wrong in the highlighting of the suggestion in the video. What did you expect to see?

I'd expect zsh to become green before I press space.

That's what it should do, yes, since pressing Enter at that point would successfully run something.

Volt-hf commented 2 years ago

I had the same issue after upgrading my Pop_os to 22.04. @danielshahaf patch has solved the problem.