diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 6981b0f..dccf63c 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -801,6 +801,9 @@ _zsh_highlight_main_highlighter_highlight_argument() local i path_eligible style path_eligible=1 + local -a match mbegin mend + local MATCH; integer MBEGIN MEND + _zsh_highlight_main_add_region_highlight $start_pos $end_pos default for (( i = 1 ; i <= end_pos - start_pos ; i += 1 )); do case "$arg[$i]" in @@ -822,14 +825,16 @@ _zsh_highlight_main_highlighter_highlight_argument() elif [[ $arg[i+1] == [*@#?-$!] ]]; then (( i += 1 )) fi;; - [*?]|\<) - # The '<' is for the <-> globbing syntax. (This function doesn't get called on redirection tokens.) - if $highlight_glob; then + *) + if $highlight_glob && [[ ${arg[$i]} == [*?] || ${arg:$i-1} == \<[0-9]#-[0-9]#\>* ]]; then + (( i += $#MATCH - 1 )) _zsh_highlight_main_add_region_highlight $start_pos $end_pos globbing path_eligible=0 break - fi;; - *) continue;; + else + continue + fi + ;; esac done diff --git a/highlighters/main/test-data/number_range-glob.zsh b/highlighters/main/test-data/number_range-glob.zsh index f8b51c9..1808492 100644 --- a/highlighters/main/test-data/number_range-glob.zsh +++ b/highlighters/main/test-data/number_range-glob.zsh @@ -28,13 +28,13 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='print <-> x<-> ' +BUFFER='print <-> x<->y ' expected_region_highlight=( '1 5 builtin' # print '7 9 globbing' # <-> - '11 14 globbing' # x<-> - '16 16 redirection' # < - '17 22 default' # foo2-3 (the filename) - '23 23 redirection' # > + '11 15 globbing' # x<-> + '17 17 redirection' # < + '18 23 default' # foo2-3 (the filename) + '24 24 redirection' # > ) diff --git a/highlighters/main/test-data/redirection-in-cmdsubst.zsh b/highlighters/main/test-data/redirection-in-cmdsubst.zsh index ea1155d..ac7a365 100644 --- a/highlighters/main/test-data/redirection-in-cmdsubst.zsh +++ b/highlighters/main/test-data/redirection-in-cmdsubst.zsh @@ -32,5 +32,5 @@ BUFFER=$': $(