zsh-syntax-highlighting/highlighters
Manish Tiwari 3d15f057c1 main: bypass the command-type cache when PATH_DIRS is removed for sudo
Per Copilot review on #987: _zsh_highlight_main__type's cache is keyed
on the command name alone, so classifying a name once under PATH_DIRS
(e.g. as a plain top-level command) would silently poison later
lookups of that same name after sudo -- and vice versa -- regardless
of the PATH_DIRS removal, since the cache lookup happens before
$options_to_set is even consulted.

Give _zsh_highlight_main__type an explicit no_cache parameter, and
add _zsh_highlight_main__type_maybe_no_pathdirs(), a small wrapper
that only shadows $options_to_set (and only bypasses the cache) when
PATH_DIRS was actually present to remove -- so a user without
PATH_DIRS set sees this codepath do nothing at all. Both call sites
in the main word-classification block now go through this wrapper
instead of duplicating the shadowing logic inline.

Strengthened sudo-path_dirs.zsh to classify the same name twice in
one buffer (plain, then sudo-prefixed) specifically to exercise this
cache interaction, not just the PATH_DIRS removal in isolation.

Verified via WSL zsh 5.9: make test passes (same 28 pre-existing
TODO failures, zero new), and the strengthened test fails as expected
(observes "command" instead of "unknown-token" on the sudo-prefixed
occurrence) when run against the pre-fix highlighter.
2026-08-25 09:57:05 +05:30
..
brackets brackets: Optimize the character iteration 2020-07-14 20:19:40 +00:00
cursor *: Change highlighters' namespace. 2016-08-16 17:53:01 +00:00
line highlighters: Rename entry points. 2016-08-16 17:51:43 +00:00
main main: bypass the command-type cache when PATH_DIRS is removed for sudo 2026-08-25 09:57:05 +05:30
pattern Use the new, unreleased zsh 'memo=' feature to remove only our own entries from $region_highlight. 2020-07-14 00:32:36 +00:00
regexp Use the new, unreleased zsh 'memo=' feature to remove only our own entries from $region_highlight. 2020-07-14 00:32:36 +00:00
root highlighters: Rename entry points. 2016-08-16 17:51:43 +00:00
README.md docs: Followup to the recent docs branch: clean up some internal cross-references. 2015-11-27 04:07:02 +00:00

README.md

zsh-syntax-highlighting / highlighters

Navigate into the individual highlighters' documentation to see what styles ($ZSH_HIGHLIGHT_STYLES keys) each highlighter defines.

Refer to the documentation on highlighters for further information.