From 517ae74172706b623b3e23894ff6c2fafefaac15 Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Sat, 17 Mar 2018 07:49:00 +0100 Subject: [PATCH] *highlight: Correctly highlight complex [[ conditions --- hsmw-highlight | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hsmw-highlight b/hsmw-highlight index 721b59a..d6ea59c 100644 --- a/hsmw-highlight +++ b/hsmw-highlight @@ -415,6 +415,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( braces_stack[1]="" style=reserved-word (( next_word = next_word | 16 )) + elif [[ $arg == "[[" ]]; then + braces_stack='A'"$braces_stack" fi ;; 'suffix alias') style=suffix-alias;; @@ -500,10 +502,16 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( case $arg in ']]') style=reserved-word + [[ $braces_stack[1] == "A" ]] && braces_stack[1]="" ;; ']') style=builtin ;; + $'\x28') + # '(' inside [[ + style=reserved-word + braces_stack='R'"$braces_stack" + ;; $'\x29') # subshell or end of array assignment if (( in_array_assignment )); then style=assign @@ -584,6 +592,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( if [[ $arg == ';' ]] && (( in_array_assignment )); then # literal newline inside an array assignment (( next_word = 2 )) + elif [[ -n "${braces_stack[(r)A]}" ]]; then + (( next_word = 2 )) else (( next_word = 1 )) highlight_glob=1 @@ -606,6 +616,8 @@ __HSMW_HIGHLIGHT_TOKENS_TYPES=( # This is the default/common codepath. (( in_redirection == 0 )) && (( this_word = next_word )) #else # Stall $this_word. done + + return 0 } # Check if $arg is a path.