mirror of
https://github.com/zsh-users/zsh-syntax-highlighting.git
synced 2025-02-27 10:25:32 +08:00
bug fix: infinite loop when cwd doesn't exist
To reproduce: % mkdir /tmp/foo % cd /tmp/foo % rmdir /tmp/foo % exec zsh -f % source ~/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh Press 'a' and zle will hang.
This commit is contained in:
parent
2d60a47cc4
commit
585696eeeb
@ -1211,14 +1211,18 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
if [[ $expanded_path[1] == / ]]; then
|
if [[ $expanded_path[1] == / ]]; then
|
||||||
tmp_path=$expanded_path
|
tmp_path=$expanded_path
|
||||||
else
|
else
|
||||||
tmp_path=$PWD/$expanded_path
|
# Unlike $PWD, ${(%):-%/} predictably expands to '.' if the current
|
||||||
|
# working directory doesn't exist.
|
||||||
|
tmp_path=${(%):-%/}/$expanded_path
|
||||||
fi
|
fi
|
||||||
tmp_path=$tmp_path:a
|
tmp_path=$tmp_path:a
|
||||||
|
|
||||||
while [[ $tmp_path != / ]]; do
|
if [[ $tmp_path == /* ]]; then
|
||||||
[[ -n ${(M)ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1
|
while [[ $tmp_path != / ]]; do
|
||||||
tmp_path=$tmp_path:h
|
[[ -n ${(M)ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1
|
||||||
done
|
tmp_path=$tmp_path:h
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
if (( in_command_position )); then
|
if (( in_command_position )); then
|
||||||
if [[ -x $expanded_path ]]; then
|
if [[ -x $expanded_path ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user