Open phy1729 opened 8 years ago
Not using _zsh_highlight_add_highlight
, and being different from all other highlighters, currently only affects the test suite. However, it also represents technical debt.
I propose we accept this technical debt: if down the road this legacy behaviour makes some future change more complicated when it should be, we can then fix this issue. This issue shouldn't be any more complicated to fix then than now, since we have to be backwards-compatible anyway.
341a3ae introduced the
_zsh_highlight_add_highlight
function and changed all highlighters except pattern to use it. For the pattern highlighter to use_zsh_highlight_add_highlight
, the interface would have to look something likethat is the values in
ZSH_HIGHLIGHT_PATTERNS
are keys forZSH_HIGHLIGHT_STYLES
. This isn't a trivial change as we're requiring people to do one of the two hard things[1] in computer science: naming things.This wouldn't be so bad if a dozen or so people used the pattern highlighter, but a quick search shows the number is closer to 500. Further, users don't gain much (if anything) from this change aside from additional lines in their config files.
A few workarounds have been suggested. The first warns the user and drops the style from the user's running configuration which breaks existing dotfiles. Having the else branch silently promote the style in
ZSH_HIGHLIGHT_PATTERNS
to the key and value inZSH_HIGHLIGHT_STYLES
would not break existing dotfiles, but would not behave correctly under the injective-test branch and feels like a temporary measure that will never be removed. AZSH_HIGHLIGHT_PATTERNS2
could be introduced with the new semantics, but converting back toZSH_HIGHLIGHT_PATTERNS
would introduce another interface change.Finally, since the style names for
ZSH_HIGHLIGHT_PATTERNS
are user defined and refer to keys inZSH_HIGHLIGHT_STYLES
, it is impossible to guarantee forward compatibility. From a compatibility standpoint, it's best for user defined patterns to stay contained in their own variable where they can't collide with futureZSH_HIGHLIGHT_STYLES
keys.For that reason I'm now of the opinion that the pattern highlighter should stay as is even if it mean it will be the odd one out.
[1]: The other of course being cache invalidation and off by one errors.