From 419fc5e9b52b49e6f9add9c0c26c0560f52865bc Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Fri, 4 Sep 2026 14:51:22 -0700 Subject: [PATCH] fix(shopify): parse every theme and keep match variables local The dynamic theme completion split the `theme list --json` payload on "${json//\{/$'\n'}", which substitutes a literal $'\n' rather than a newline. Only the first theme was ever offered. Split on a newline held in a variable instead. Both completion helpers used =~ and (#b) backreferences without declaring $match, leaving match, MATCH, mbegin and mend set in the user's shell. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01LNDR8NjvPSgHbjcQurMHW9 --- plugins/shopify/_shopify | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/shopify/_shopify b/plugins/shopify/_shopify index 050b1e522..e001a68d4 100644 --- a/plugins/shopify/_shopify +++ b/plugins/shopify/_shopify @@ -11,6 +11,9 @@ _shopify_environments() { setopt localoptions extendedglob local -a envs local file line + # (#b) backreferences set $match, which would otherwise be left global. + local MATCH MBEGIN MEND + local -a match mbegin mend for file in shopify.theme.toml shopify.app.toml; do [[ -r "$file" ]] || continue for line in ${(f)"$(< $file)"}; do @@ -31,6 +34,10 @@ _shopify_themes() { local cache_file="$ZSH_CACHE_DIR/shopify-themes${key: -100}" local -a themes fresh local json split entry id name role + # $match and friends are set by =~ and would otherwise be left global. + local MATCH MBEGIN MEND + local -a match mbegin mend + local nl=$'\n' # Reuse the cached list for five minutes. fresh=(${cache_file}(Nms-300)) @@ -39,7 +46,7 @@ _shopify_themes() { else json="$(command shopify theme list --json 2>/dev/null)" || return 1 # One chunk per object, in zsh, so there is no dependency on jq. - split="${json//\{/$'\n'}" + split="${json//\{/$nl}" for entry in ${(f)split}; do id="" name="" role="" [[ $entry =~ '"id":[[:space:]]*([0-9]+)' ]] && id=$match[1]