Description
First of all, thank you for your work on this plugin. I am trying to create a custom highlighter, and it works perfectly. The issue is that the next commands also get highlighted at the same positions the prior command was highlighted at.
I created a minimal example to reproduce this, which I tried in a clean containerized environment:
.zshrc:
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(main brackets demo)
source zsh-syntax-highlighting-master/zsh-syntax-highlighting.zsh
zsh-syntax-highlighting-master/highlighters/demo/demo-highlighter.zsh:
: ${ZSH_HIGHLIGHT_STYLES[demo:red]:=fg=red,bold}
function _zsh_highlight_highlighter_demo_predicate {
[[ $BUFFER[1,4] == echo ]]
}
function _zsh_highlight_highlighter_demo_paint {
_zsh_highlight_add_highlight 4 10 demo:red
}
An example output can be seen in this image.
Unless I understood the docs incorrectly, the paint should apply only to the echo
calls. I tried similar simplistic conditions, such as the length of $BUFFER
being above a given number, with similar results.
If there's something I'm missing, I'd appreciate any pointers. Also, I could not get the main
highlighter to apply unless explicitly added to ZSH_HIGHLIGHT_HIGHLIGHTERS
, which I suppose is unrelated but also contrary to documentation.