Skip to content

Commit f1c1715

Browse files
Atyanshclaude
andcommitted
Fix permission errors when used with zsh-users/zsh-syntax-highlighting
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 <noreply@anthropic.com>
1 parent 69b77b1 commit f1c1715

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

zsh-syntax-highlighting-filetypes.zsh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ _zsh_highlight-zle-buffer() {
6161
local cache_place=${zsh_highlight_caches[i]}
6262
local -a rh; rh=($region_highlight)
6363
{
64-
"$func"
64+
[[ -n "$func" ]] && whence "$func" &>/dev/null && "$func"
6565
} always {
66-
: ${(PA)cache_place::=${region_highlight:#(${(~j.|.)rh})}}
66+
[[ -n "$cache_place" && "$cache_place" == [a-zA-Z_]* ]] && : ${(PA)cache_place::=${region_highlight:#(${(~j.|.)rh})}}
6767
}
6868
done
6969
} always {
@@ -78,7 +78,7 @@ _zsh_highlight-zle-buffer-p() {
7878
local region_highlight_size="$1" highlight_predicate="$2"
7979
# If any highlightings are not taken into account, asume it is needed.
8080
# This holds for some up/down-history commands, for example.
81-
((region_highlight_size == 0)) || "$highlight_predicate"
81+
((region_highlight_size == 0)) || { [[ -n "$highlight_predicate" ]] && "$highlight_predicate"; } 2>/dev/null
8282
}
8383

8484
# Whether the command line buffer is modified or not.

0 commit comments

Comments
 (0)