Description
As pointed out in #747 (comment) (by @jnooree), the regexp
highlighter runs under whichever setting of the RE_MATCH_PCRE
option was in effect when _zsh_highlighter
was invoked.
This gives rise to two converse issues:
-
If somebody, for whatever reason, calls
_zsh_highlight
with theRE_MATCH_PCRE
option temporarily set to the opposite of whatever it is normally set to when z-sy-h is invoked (e.g.,some_other_plugin() { setopt localoptions norematchpcre; _zsh_highlight }
in a setup where that option is set when z-sy-h is invoked the usual way), theregexp
highlighter will parse its patterns according to the new value of the option. This may cause patterns to fail to compile (if they use PCRE features that aren't supported by the localregcomp(3)
, or vice versa) or to match incorrectly. In any case, depending on the option's current setting doesn't sound right: whether a pattern is an ERE pattern or a PCRE pattern doesn't depend on the option settings at the time of any particular function call. -
Running the driver under canonicalized option settings (Canonicalize option settings earlier #536) would constitute a breaking change for users who deliberately set that option and use PCRE patterns in
ZSH_HIGHLIGHT_REGEXP
.
One straightforward way to fix both issues is to extend the regexp
highlighter's API with a way to specify whether matching should use the -regex-match
operator or the -pcre-match
operator. Should such a setting be per pattern? That would provide modularity: the highlighter could be used by different modules and those modules won't all need to agree on whether to use PCRE or ERE.
An alternative way to fix (2) only would be to query ${zsyh_user_options[rematchpcre]}
.
Activity