zsh-syntax-highlighting: Works so slow when I try to paste long string to terminal
I am just using main highlighter. At first, I thought if I just disable some styles, it will work fine. So I disabled all quoted-argument.
When I paste magnet:?xt=..t.nz after " into the terminal:
aria2c "magnet:?xt=urn:btih:90...er.fastcast.nz"
The highlight is gone, but it’s still really slow! I really love the highlighting, how can I make it faster?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 10
- Comments: 23 (10 by maintainers)
Commits related to this issue
- Fixed slow paste issue with zsh-syntax-highlighting plugin Reference: https://github.com/zsh-users/zsh-syntax-highlighting/issues/513 Without `ZSH_HIGHLIGHT_MAXLENGTH=20` in `~/.zshrc`, pasting mult... — committed to flakrat/dotfiles by flakrat 5 years ago
- zsh-syntax-highlighting slowness when pasting long lines: https://github.com/zsh-users/zsh-syntax-highlighting/issues/513#issuecomment-379145092 — committed to mmercurio/dotfiles by mmercurio 2 years ago
this gist works fine.
I viewed #86 and some of the source code again, came up with a temporary solution:
Add
export ZSH_HIGHLIGHT_MAXLENGTH=60in file.zshrcNow it will just stop parse or highlight any long string, and this works well for me.
Thanks for your help!!
In my experience, if you paste something into the terminal and it’s taking a long time to draw, you can push any button on the keyboard (e.g. right arrow) and it’ll give up highlighting and draw the text.
(Related to #240.)
Being slow with large inputs is a known issue. There seems to be two main causes:
I’ve briefly looked at solving the first in zsh, but I haven’t had time to make a complete patch.
With regards to disabling styles, setting a style to none doesn’t disable the code that parses for that style. We could add a flag to disable
_zsh_highlight_main_highlighter_highlight_argument, but that would disableand once #512 is merged the highlighting of command and process substitution and their contents.
If that’s acceptable, you can add
return 0as the first command in_zsh_highlight_main_highlighter_highlight_argument. We could add a flag to do the same, but I think long term it’d be preferable to fix the quadratic issues in zsh.This comment fixed it for me: https://github.com/zsh-users/zsh-syntax-highlighting/issues/295#issuecomment-214581607 and the issue is probably a duplicate of this one
forresthopkinsa that worked thanks