zdharma-continuum / fast-syntax-highlighting

Feature-rich syntax highlighting for ZSH
BSD 3-Clause "New" or "Revised" License
1.15k stars 75 forks source link

[bug]: No highlighting until key is pressed #46

Closed ItsDrike closed 1 year ago

ItsDrike commented 1 year ago

Describe the bug

Syntax highlighting only appears after another key is pressed, so if the command is obtained from history, there's no syntax highlighting until another key press.

Steps to reproduce

  1. Type in command echo "Hello World" letter by letter, and run it (and see syntax highlighting work)
  2. Now press up arrow, to obtain the last command from history
  3. Observe echo "Hello World" command appear, but without any syntax highlighting
  4. Press any key, including the arrow keys (such as arrow right)
  5. Observe the command text suddenly getting syntax highlighting

Similarly, with hist_verify option, as the expanded command is shown, there's no highlighting until a key is pressed

Expected behavior

The highlighting should appear immediately, not only after another key is pressed. I often just search the history for a command by pressing the up arrow multiple times, and I want to see the highlighting in the commands I go over, however currently, I need to press another key (like arrow right) between each result to get the highlighting to appear, which is incredibly annoying.

Screenshots and recordings

https://asciinema.org/a/kv7tJt9WRxWd2F8CjmUqhHz4d

Operating System & Version

Arch Linux 6.1.9-arch1-1; linux-gnu | pc | x86_64 | x86_64 | x86_64 unknown

Zsh version

zsh 5.9 (x86_64-pc-linux-gnu)

Terminal emulator

alacritty

If using WSL on Windows, which version of WSL

None

Additional context

With https://github.com/zsh-users/zsh-syntax-highlighting the highlighting works properly and no additional key presses are needed. So this is clearly possible and not some kind of terminal emulator limitation or anything like that.

I should note that I am on wayland (specifically Hyprland), and that Alacritty is running natively under wayland, if that makes some difference.

ItsDrike commented 1 year ago

Turns out the issue was that I was loading the extension before doing everything else in zshrc rather than loading it last. Moving the zgenom source line below everything else fixed the issue