fix(vcs_info): wrap autoload stubs and keep sourcing non-fatal

An autoload stub for VCS_INFO_formats has no post-backend line to patch,
so treat it like not loaded and install the lazy wrapper. Return 0 when
regexp-replace is unavailable, matching the previous || return 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Robby RussellandClaude Opus 5.5 committed 2026-11-24 11:43:44 -08:00
1 parent 61f12e078f
commit 57e1e76e27
1 file changed
+3 -2
+3 -2
View File
@@ -43,9 +43,10 @@
# vcs_info. `autoload` doesn't replace an already defined function, so this
# wrapper survives a later `autoload -Uz vcs_info` in a theme or .zshrc, and
# vcs_info's own `autoload -Uz VCS_INFO_formats`.
if (( $+functions[VCS_INFO_formats] )); then
# An autoload stub counts as not loaded yet, so it gets the wrapper too.
if (( $+functions[VCS_INFO_formats] )) && [[ $functions[VCS_INFO_formats] != 'builtin autoload -X'* ]]; then
() {
autoload -Uz +X regexp-replace 2>/dev/null || return 1
autoload -Uz +X regexp-replace 2>/dev/null || return 0
# We use $tmp here because it's already a local variable in VCS_INFO_formats
local PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'