From 47d6dac133094e0a60c9e1fcbb28a810a98fa0ec Mon Sep 17 00:00:00 2001 From: "Sam Jorna (wraeth)" Date: Thu, 30 Aug 2018 10:12:55 +1000 Subject: [PATCH] main-highlighter: Probe dirs after blacklist Move tests on the highlight path until after the blacklist is checked so that blacklisted paths are not tested. This should prevent hangs on dead remote filesystems provided the path is blacklisted in X_ZSH_HIGHLIGHT_DIRS_BLACKLIST. Updated tests to 'default' highlight as the blacklist is now checked before the path is tested. Bug: https://github.com/zsh-users/zsh-syntax-highlighting/issues/528 --- highlighters/main/main-highlighter.zsh | 5 +++-- highlighters/main/test-data/dirs_blacklist.zsh | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 8b373ab..83571f6 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -761,8 +761,6 @@ _zsh_highlight_main_highlighter_check_path() REPLY=path [[ -z $expanded_path ]] && return 1 - [[ -L $expanded_path ]] && return 0 - [[ -e $expanded_path ]] && return 0 # Check if this is a blacklisted path if [[ $expanded_path[1] == / ]]; then @@ -777,6 +775,9 @@ _zsh_highlight_main_highlighter_check_path() tmp_path=$tmp_path:h done + [[ -L $expanded_path ]] && return 0 + [[ -e $expanded_path ]] && return 0 + # Search the path in CDPATH local cdpath_dir for cdpath_dir in $cdpath ; do diff --git a/highlighters/main/test-data/dirs_blacklist.zsh b/highlighters/main/test-data/dirs_blacklist.zsh index 0d4d666..7fff7e2 100644 --- a/highlighters/main/test-data/dirs_blacklist.zsh +++ b/highlighters/main/test-data/dirs_blacklist.zsh @@ -34,7 +34,7 @@ X_ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo) expected_region_highlight=( '1 1 builtin' # : - '3 9 path' # foo/bar - "11 $(( 14 + $#PWD )) path" # $PWD/foo + '3 9 default' # foo/bar + "11 $(( 14 + $#PWD )) default" # $PWD/foo "$(( 16 + $#PWD )) $(( 20 + $#PWD )) default" # foo/b )