From f1c17150eea2c29852bd782cac2c81b23ce4fa86 Mon Sep 17 00:00:00 2001 From: Atyansh Jaiswal Date: Sat, 22 Nov 2025 17:46:49 -0800 Subject: [PATCH] Fix permission errors when used with zsh-users/zsh-syntax-highlighting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using this plugin alongside zsh-users/zsh-syntax-highlighting, pressing backspace or enter on an empty command line produces errors: - _zsh_highlight-zle-buffer-p:4: permission denied: - _zsh_highlight-zle-buffer:25: permission denied: - _zsh_highlight-zle-buffer:27: not an identifier: This happens because both plugins share internal arrays and the newer zsh-users plugin registers entries that are incompatible. Fix: - Validate highlight_predicate is non-empty before executing - Validate func exists as callable function before invoking - Validate cache_place is a valid identifier before assignment Builds on #12 with additional guards. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- zsh-syntax-highlighting-filetypes.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zsh-syntax-highlighting-filetypes.zsh b/zsh-syntax-highlighting-filetypes.zsh index c6eb94d..f7da2db 100644 --- a/zsh-syntax-highlighting-filetypes.zsh +++ b/zsh-syntax-highlighting-filetypes.zsh @@ -61,9 +61,9 @@ _zsh_highlight-zle-buffer() { local cache_place=${zsh_highlight_caches[i]} local -a rh; rh=($region_highlight) { - "$func" + [[ -n "$func" ]] && whence "$func" &>/dev/null && "$func" } always { - : ${(PA)cache_place::=${region_highlight:#(${(~j.|.)rh})}} + [[ -n "$cache_place" && "$cache_place" == [a-zA-Z_]* ]] && : ${(PA)cache_place::=${region_highlight:#(${(~j.|.)rh})}} } done } always { @@ -78,7 +78,7 @@ _zsh_highlight-zle-buffer-p() { local region_highlight_size="$1" highlight_predicate="$2" # If any highlightings are not taken into account, asume it is needed. # This holds for some up/down-history commands, for example. - ((region_highlight_size == 0)) || "$highlight_predicate" + ((region_highlight_size == 0)) || { [[ -n "$highlight_predicate" ]] && "$highlight_predicate"; } 2>/dev/null } # Whether the command line buffer is modified or not.