From a6d105131c60ded13a036ba0acf47688cc13a3a7 Mon Sep 17 00:00:00 2001 From: Julien Nicoulaud Date: Tue, 6 Sep 2011 19:21:12 +0200 Subject: [PATCH] Fix #21: No highlighting when using tilde --- highlighters/main/main-highlighter.zsh | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index e0d1439..b30f75c 100755 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -85,10 +85,10 @@ _zsh_highlight_main_highlighter() *': function') style=$ZSH_HIGHLIGHT_STYLES[function];; *': command') style=$ZSH_HIGHLIGHT_STYLES[command];; *': hashed') style=$ZSH_HIGHLIGHT_STYLES[hashed-command];; - *) if _zsh_highlight_main_highlighter_check_assign "$arg"; then + *) if _zsh_highlight_main_highlighter_check_assign; then style=$ZSH_HIGHLIGHT_STYLES[assign] new_expression=true - elif _zsh_highlight_main_highlighter_check_path "$arg"; then + elif _zsh_highlight_main_highlighter_check_path; then style=$ZSH_HIGHLIGHT_STYLES[path] elif [[ $arg[0,1] = $histchars[0,1] ]]; then style=$ZSH_HIGHLIGHT_STYLES[history-expansion] @@ -109,7 +109,7 @@ _zsh_highlight_main_highlighter() ;; '`'*'`') style=$ZSH_HIGHLIGHT_STYLES[back-quoted-argument];; *"*"*) $highlight_glob && style=$ZSH_HIGHLIGHT_STYLES[globbing] || style=$ZSH_HIGHLIGHT_STYLES[default];; - *) if _zsh_highlight_main_highlighter_check_path "$arg"; then + *) if _zsh_highlight_main_highlighter_check_path; then style=$ZSH_HIGHLIGHT_STYLES[path] elif [[ $arg[0,1] = $histchars[0,1] ]]; then style=$ZSH_HIGHLIGHT_STYLES[history-expansion] @@ -128,7 +128,6 @@ _zsh_highlight_main_highlighter() # Check if the argument is variable assignment _zsh_highlight_main_highlighter_check_assign() { - local arg="$1" setopt localoptions extended_glob [[ ${(Q)arg} == [[:alpha:]_]([[:alnum:]_])#=* ]] } @@ -136,11 +135,10 @@ _zsh_highlight_main_highlighter_check_assign() # Check if the argument is a path. _zsh_highlight_main_highlighter_check_path() { - local arg="$1" - [[ -z ${(Q)arg} ]] && return 1 - [[ -e ${(Q)arg} ]] && return 0 - [[ ! -e ${(Q)arg:h} ]] && return 1 - [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos && -n $(print ${(Q)arg}*(N)) ]] && return 0 + [[ -z ${(Q)~arg} ]] && return 1 + [[ -e ${(Q)~arg} ]] && return 0 + [[ ! -e ${(Q)~arg:h} ]] && return 1 + [[ ${BUFFER[1]} != "-" && ${#BUFFER} == $end_pos && -n $(print ${(Q)~arg}*(N)) ]] && return 0 return 1 }