Update zsh-syntax-highlighting plugin
authorJoerg Jaspert <joerg@debian.org>
Wed, 26 Dec 2018 13:28:47 +0000 (14:28 +0100)
committerJoerg Jaspert <joerg@debian.org>
Wed, 26 Dec 2018 13:28:47 +0000 (14:28 +0100)
153 files changed:
.zsh/zsh-syntax-highlighting/.travis.yml
.zsh/zsh-syntax-highlighting/COPYING.md
.zsh/zsh-syntax-highlighting/HACKING.md
.zsh/zsh-syntax-highlighting/INSTALL.md
.zsh/zsh-syntax-highlighting/README.md
.zsh/zsh-syntax-highlighting/docs/highlighters.md
.zsh/zsh-syntax-highlighting/docs/highlighters/main.md
.zsh/zsh-syntax-highlighting/docs/highlighters/pattern.md
.zsh/zsh-syntax-highlighting/docs/highlighters/regexp.md [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/brackets/brackets-highlighter.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/cursor-matchingbracket-line-finish.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/cursor-matchingbracket.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/empty-styles.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/loop-styles.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/mismatch-patentheses.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/near-quotes.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/nested-parentheses.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/only-error.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/quoted-patentheses.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/simple-parentheses.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses.zsh
.zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/unclosed-patentheses2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/main-highlighter.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-assignment1.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-comment1.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-comment2.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-complex.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-empty.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-loop.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-nested-precommand.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-nested.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument1.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument2.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-quoted.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-redirect.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-self.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-to-dir.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/anonymous-function.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-append.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-argv.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-array.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-array2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-array3.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-not-array.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-not-array2.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-semicolon.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-subshell.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/back-quoted-argument.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/back-quoted-open.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/backslash-space.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-assign-array.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-assign-scalar.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-pipeline.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-matching1.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-matching2.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-mismatch7.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-premature-termination.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-in-assignment.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-unclosed.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/commandseparator.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/comment-followed.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/comment-leading.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/comments.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/commmand-parameter.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/control-flow.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/cthulhu.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dirs_blacklist.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dollar-dollar.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dollar-noise.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dollar-paren.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dollar-quoted.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dollar-quoted2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dollar-quoted3.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/double-hyphen-option.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/double-quoted.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/double-quoted2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/double-quoted3.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/double-quoted4.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/empty-command.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/empty-command2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/empty-line.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/escaped-single-quote.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/exec-redirection1.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/function-altsyntax.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/function.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/glob.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/globs-with-quoting.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-escaped.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-no.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-unescaped.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-double-quoted-yes.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/history-expansion.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/multiline-string.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/multiline-string2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/multiple-quotes.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob-alias.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob-always.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob1.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob3.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob4.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/number_range-glob.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/off-by-one.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/option-with-quotes.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/order-path-after-dollar.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/order-path-before-globbing.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/parameter-star.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-broken-symlink.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word3.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word4.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-separators.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-separators2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-space.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-tilde-home3.zsh [moved from .zsh/zsh-syntax-highlighting/highlighters/brackets/test-data/nested-quote.zsh with 96% similarity]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path_prefix.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path_prefix2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path_prefix3.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand-unknown-option.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand3.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand4.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/prefix-redirection.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution-redirection-isnt-globbing.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution2.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/quoted-command-substitution-empty.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/rc-quotes.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection-comment.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection-in-cmdsubst.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection3.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/reserved-word.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/subshell.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/sudo-command.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/sudo-comment.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/sudo-redirection.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/sudo-redirection2.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/sudo-redirection3.zsh
.zsh/zsh-syntax-highlighting/highlighters/main/test-data/vi-linewise-mode.zsh
.zsh/zsh-syntax-highlighting/highlighters/regexp/README.md [new symlink]
.zsh/zsh-syntax-highlighting/highlighters/regexp/regexp-highlighter.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/complex.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/subexpression.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/word-boundary.zsh [new file with mode: 0644]
.zsh/zsh-syntax-highlighting/tests/README.md
.zsh/zsh-syntax-highlighting/tests/tap-colorizer.zsh
.zsh/zsh-syntax-highlighting/tests/test-highlighting.zsh
.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

index db5dbc4..cea0ad9 100644 (file)
@@ -3,6 +3,11 @@ sudo: required
 
 env:
   - ZSH=master
+  - ZSH=5.6.2
+  - ZSH=5.6.1
+  - ZSH=5.6
+  - ZSH=5.5.1
+  - ZSH=5.5
   - ZSH=5.4.2
   - ZSH=5.4.1
   - ZSH=5.4
@@ -28,7 +33,7 @@ env:
   - ZSH=4.3.12
   - ZSH=4.3.11
 
-script: docker run -v $PWD:/work -w /work zshusers/zsh-${ZSH} /bin/sh -c 'make test'
+script: docker run -v $PWD:/work -w /work zshusers/zsh-${ZSH} /bin/sh -c 'install_packages make procps && make test'
 
 notifications:
   webhooks:
index 3d6b811..22eea4f 100644 (file)
@@ -1,4 +1,4 @@
-Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
+Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without modification, are permitted
index 39d82fa..5266a33 100644 (file)
@@ -44,14 +44,14 @@ tests must set the `bracket-level-#` keys themselves.  For example:
       "10 10 bracket-level-1" # )
     )
 
-Testing the `pattern` highlighter
----------------------------------
-
-Because the `pattern` highlighter modifies `region_highlight` directly instead
-of using `_zsh_highlight_add_highlight`, the test harness cannot get the
-`ZSH_HIGHLIGHT_STYLES` keys.  Therefore, when writing tests, use the style
-itself as third word (cf. the [documentation for `expected_region_highlight`]
-(docs/highlighters.md)).  For example:
+Testing the `pattern` and `regexp` highlighters
+-----------------------------------------------
+
+Because the `pattern` and `regexp` highlighters modifies `region_highlight`
+directly instead of using `_zsh_highlight_add_highlight`, the test harness
+cannot get the `ZSH_HIGHLIGHT_STYLES` keys.  Therefore, when writing tests, use
+the style itself as third word (cf. the
+[documentation for `expected_region_highlight`](docs/highlighters.md)).  For example:
 
     ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
 
index ca1bfa7..468e9bd 100644 (file)
@@ -26,22 +26,24 @@ How to install
 [obs-repository]: https://software.opensuse.org//download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
 [void-package]: https://github.com/voidlinux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
 
+See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions)
+
 
 ### In your ~/.zshrc
 
 Simply clone this repository and source the script:
 
-        git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
-        echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
+    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
+    echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
 
   Then, enable syntax highlighting in the current interactive shell:
 
-        source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
+    source ./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
 
   If `git` is not installed, download and extract a snapshot of the latest
   development tree from:
 
-        https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
+    https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz
 
   Note the `source` command must be **at the end** of `~/.zshrc`.
 
@@ -53,9 +55,10 @@ Note that `zsh-syntax-highlighting` must be the last plugin sourced.
 The zsh-syntax-highlighting authors recommend manual installation over the use
 of a framework or plugin manager.
 
-This list is incomplete as there are too many [frameworks / plugin managers]
-(https://github.com/unixorn/awesome-zsh-plugins#frameworks) to list them all
-here.
+This list is incomplete as there are too many
+[frameworks / plugin managers][framework-list] to list them all here.
+
+[framework-list]: https://github.com/unixorn/awesome-zsh-plugins#frameworks
 
 #### [Antigen](https://github.com/zsh-users/antigen)
 
@@ -66,21 +69,22 @@ your `.zshrc`.
 
 1. Clone this repository in oh-my-zsh's plugins directory:
 
-        git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
+       git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
 
 2. Activate the plugin in `~/.zshrc`:
 
-        plugins=( [plugins...] zsh-syntax-highlighting)
+       plugins=( [plugins...] zsh-syntax-highlighting)
 
 3. Source `~/.zshrc`  to take changes into account:
 
-        source ~/.zshrc
+       source ~/.zshrc
 
 #### [Prezto](https://github.com/sorin-ionescu/prezto)
 
-Zsh-syntax-highlighting is included with Prezto. See the [Prezto documentation]
-(https://github.com/sorin-ionescu/prezto/tree/master/modules/syntax-highlighting)
-to enable and configure highlighters.
+Zsh-syntax-highlighting is included with Prezto. See the
+[Prezto documentation][prezto-docs] to enable and configure highlighters.
+
+[prezto-docs]: https://github.com/sorin-ionescu/prezto/tree/master/modules/syntax-highlighting
 
 #### [zgen](https://github.com/tarjoilija/zgen)
 
index 855be9e..08af2b6 100644 (file)
@@ -1,15 +1,15 @@
 zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis]
 =======================
 
-**[Fish shell][fish]-like like syntax highlighting for [Zsh][zsh].**
+**[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].**
 
 *Requirements: zsh 4.3.11+.*
 
 [fish]: http://www.fishshell.com/
 [zsh]: http://www.zsh.org/
 
-This package provides syntax highlighing for the shell zsh.  It enables
-highlighing of commands whilst they are typed at a zsh prompt into an
+This package provides syntax highlighting for the shell zsh.  It enables
+highlighting of commands whilst they are typed at a zsh prompt into an
 interactive terminal.  This helps in reviewing commands before running
 them, particularly in catching syntax errors.
 
index c0f79bc..642d2bd 100644 (file)
@@ -78,6 +78,14 @@ To create your own `acme` highlighter:
           _zsh_highlight_add_highlight 0 $#BUFFER acme:aurora
         }
 
+  If you need to test which options the user has set, test `zsyh_user_options`
+  with a sensible default if the option is not present in supported zsh
+  versions. For example:
+
+        [[ ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]
+
+  The option name must be all lowercase with no underscores and not an alias.
+
 * Name your own functions and global variables `_zsh_highlight_acme_*`.
 
     - In zsh-syntax-highlighting 0.4.0 and earlier, the entrypoints 
index bf83820..005fc4d 100644 (file)
@@ -32,19 +32,34 @@ This highlighter defines the following styles:
 * `path_prefix_pathseparator` - path separators in prefixes of existing filenames (`/`); if unset, `path_prefix` is used (default)
 * `globbing` - globbing expressions (`*.txt`)
 * `history-expansion` - history expansion expressions (`!foo` and `^foo^bar`)
-* `single-hyphen-option` - single hyphen options (`-o`)
-* `double-hyphen-option` - double hyphen options (`--option`)
-* `back-quoted-argument` - backquoted expressions (`` `foo` ``)
-* `single-quoted-argument` - single quoted arguments (`` 'foo' ``)
-* `double-quoted-argument` - double quoted arguments (`` "foo" ``)
-* `dollar-quoted-argument` - dollar quoted arguments (`` $'foo' ``)
+* `command-substitution` - command substitutions (`$(echo foo)`)
+* `command-substitution-unquoted` - an unquoted command substitution (`$(echo foo)`)
+* `command-substitution-quoted` - a quoted command substitution (`"$(echo foo)"`)
+* `command-substitution-delimiter` - command substitution delimiters (`$(` and `)`)
+* `command-substitution-delimiter-unquoted` - an unquoted command substitution delimiters (`$(` and `)`)
+* `command-substitution-delimiter-quoted` - a quoted command substitution delimiters (`"$(` and `)"`)
+* `process-substitution` - process substitutions (`<(echo foo)`)
+* `process-substitution-delimiter` - process substitution delimiters (`<(` and `)`)
+* `single-hyphen-option` - single-hyphen options (`-o`)
+* `double-hyphen-option` - double-hyphen options (`--option`)
+* `back-quoted-argument` - backtick command substitution (`` `foo` ``)
+* `back-quoted-argument-unclosed` - unclosed backtick command substitution (`` `foo ``)
+* `back-quoted-argument-delimiter` - backtick command substitution delimiters (`` ` ``)
+* `single-quoted-argument` - single-quoted arguments (`` 'foo' ``)
+* `single-quoted-argument-unclosed` - unclosed single-quoted arguments (`` 'foo ``)
+* `double-quoted-argument` - double-quoted arguments (`` "foo" ``)
+* `double-quoted-argument-unclosed` - unclosed double-quoted arguments (`` "foo ``)
+* `dollar-quoted-argument` - dollar-quoted arguments (`` $'foo' ``)
+* `dollar-quoted-argument-unclosed` - unclosed dollar-quoted arguments (`` $'foo ``)
+* `rc-quote` - two single quotes inside single quotes when the `RC_QUOTES` option is set (`` 'foo''bar' ``)
 * `dollar-double-quoted-argument` - parameter expansion inside double quotes (`$foo` inside `""`)
-* `back-double-quoted-argument` -  back double quoted arguments (`\x` inside `""`)
-* `back-dollar-quoted-argument` -  back dollar quoted arguments (`\x` inside `$''`)
-* `assign` - parameter assignments
+* `back-double-quoted-argument` -  backslash escape sequences inside double-quoted arguments (`\"` in `"foo\"bar"`)
+* `back-dollar-quoted-argument` -  backslash escape sequences inside dollar-quoted arguments (`\x` in `$'\x48'`)
+* `assign` - parameter assignments (`x=foo` and `x=( )`)
 * `redirection` - redirection operators (`<`, `>`, etc)
 * `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
-* `arg0` - a command word other than one of those enumrated above (other than a command, precommand, alias, function, or shell builtin command).
+* `named-fd` - named file descriptor (`echo foo {fd}>&2`)
+* `arg0` - a command word other than one of those enumerated above (other than a command, precommand, alias, function, or shell builtin command).
 * `default` - everything else
 
 To override one of those styles, change its entry in `ZSH_HIGHLIGHT_STYLES`,
@@ -66,6 +81,13 @@ The syntax for values is the same as the syntax of "types of highlighting" of
 the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
 manual page][zshzle-Character-Highlighting].
 
+#### Parameters
+
+To avoid partial path lookups on a path, add the path to the `X_ZSH_HIGHLIGHT_DIRS_BLACKLIST` array.
+This interface is still experimental.
+
+    X_ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
+
 ### Useless trivia
 
 #### Forward compatibility.
index 3ad5f24..8853db0 100644 (file)
@@ -9,6 +9,9 @@ This is the `pattern` highlighter, that highlights user-defined patterns.
 To use this highlighter, associate patterns with styles in the
 `ZSH_HIGHLIGHT_PATTERNS` associative array, for example in `~/.zshrc`:
 
+    # Declare the variable
+    typeset -A ZSH_HIGHLIGHT_PATTERNS
+
     # To have commands starting with `rm -rf` in red:
     ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
 
diff --git a/.zsh/zsh-syntax-highlighting/docs/highlighters/regexp.md b/.zsh/zsh-syntax-highlighting/docs/highlighters/regexp.md
new file mode 100644 (file)
index 0000000..2078525
--- /dev/null
@@ -0,0 +1,28 @@
+zsh-syntax-highlighting / highlighters / regexp
+------------------------------------------------
+
+This is the `regexp` highlighter, that highlights user-defined regular
+expressions. It's similar to the `pattern` highlighter, but allows more complex
+patterns.
+
+### How to tweak it
+
+To use this highlighter, associate regular expressions with styles in the
+`ZSH_HIGHLIGHT_REGEXP` associative array, for example in `~/.zshrc`:
+
+    typeset -A ZSH_HIGHLIGHT_PATTERNS
+    ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold)
+
+This will highlight "sudo" only as a complete word, i.e., "sudo cmd", but not
+"sudoedit"
+
+The syntax for values is the same as the syntax of "types of highlighting" of
+the zsh builtin `$zle_highlight` array, which is documented in [the `zshzle(1)`
+manual page][zshzle-Character-Highlighting].
+
+See also: [regular expressions tutorial][perlretut], zsh regexp operator `=~`
+in [the `zshmisc(1)` manual page][zshmisc-Conditional-Expressions]
+
+[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
+[perlretut]: http://perldoc.perl.org/perlretut.html
+[zshmisc-Conditional-Expressions]: http://zsh.sourceforge.net/Doc/Release/Conditional-Expressions.html#Conditional-Expressions
index cb09b40..fc71f2a 100644 (file)
@@ -1,5 +1,5 @@
 # -------------------------------------------------------------------------------------------------
-# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
+# Copyright (c) 2010-2017 zsh-syntax-highlighting contributors
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without modification, are permitted
@@ -70,10 +70,6 @@ _zsh_highlight_highlighter_brackets_paint()
           levelpos[$pos]=-1
         fi
         ;;
-      ['"'\'])
-        # Skip everything inside quotes
-       pos=$BUFFER[(ib:pos+1:)$char]
-        ;;
     esac
   done
 
index 5e9cf62..e05b4e9 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-3]=
@@ -35,5 +37,11 @@ BUFFER=': ((( )))'
 CURSOR=2 # cursor is zero-based
 
 expected_region_highlight=(
+  "3 3 bracket-level-1"
+  "4 4 bracket-level-2"
+  "5 5 bracket-level-3"
+  "7 7 bracket-level-3"
+  "8 8 bracket-level-2"
+  "9 9 bracket-level-1"
   "9 9 cursor-matchingbracket"
 )
index a5be21d..e5cfcdf 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-3]=
index f40226f..5cc588f 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
 
index b7cc2cb..49f002b 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
+ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
 
 BUFFER=': {"{x}"}'
 
 expected_region_highlight=(
   "3 3 bracket-level-1"
-  "4 8 NONE"
+  "5 5 bracket-level-2"
+  "7 7 bracket-level-2"
   "9 9 bracket-level-1"
 )
index 413394f..21a20fb 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-3]=
index 186d0b9..2ccfbab 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
 
index 941d092..d3f6560 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
 ZSH_HIGHLIGHT_STYLES[bracket-level-2]=
 
index 41b6836..2c489c3 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+unsorted=1
+
 ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
 
 BUFFER='echo {x})'
index d4a396a..06839ce 100644 (file)
@@ -1,5 +1,5 @@
 # -------------------------------------------------------------------------------------------------
-# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
+# Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without modification, are permitted
 : ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
 : ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
 : ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue}
+: ${ZSH_HIGHLIGHT_STYLES[command-substitution]:=none}
+: ${ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]:=fg=magenta}
+: ${ZSH_HIGHLIGHT_STYLES[process-substitution]:=none}
+: ${ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]:=fg=magenta}
 : ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none}
 : ${ZSH_HIGHLIGHT_STYLES[double-hyphen-option]:=none}
 : ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none}
+: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]:=fg=magenta}
 : ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow}
 : ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow}
 : ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow}
+: ${ZSH_HIGHLIGHT_STYLES[rc-quote]:=fg=cyan}
 : ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan}
 : ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan}
 : ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
 : ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
 : ${ZSH_HIGHLIGHT_STYLES[redirection]:=none}
 : ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
+: ${ZSH_HIGHLIGHT_STYLES[named-fd]:=none}
 : ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
 
 # Whether the highlighter should be called or not.
@@ -66,41 +73,58 @@ _zsh_highlight_main_add_region_highlight() {
   integer start=$1 end=$2
   shift 2
 
-  if (( $+argv[2] )); then
-    # Caller specified inheritance explicitly.
-  else
-    # Automate inheritance.
-    typeset -A fallback_of; fallback_of=(
-        alias arg0
-        suffix-alias arg0
-        builtin arg0
-        function arg0
-        command arg0
-        precommand arg0
-        hashed-command arg0
-        
-        path_prefix path
-        # The path separator fallback won't ever be used, due to the optimisation
-        # in _zsh_highlight_main_highlighter_highlight_path_separators().
-        path_pathseparator path
-        path_prefix_pathseparator path_prefix
-    )
-    local needle=$1 value
-    while [[ -n ${value::=$fallback_of[$needle]} ]]; do
-      unset "fallback_of[$needle]" # paranoia against infinite loops
-      argv+=($value)
-      needle=$value
-    done
-  fi
+  (( highlighted_alias )) && return
+  (( in_alias )) && highlighted_alias=1
+
+  # The calculation was relative to $buf but region_highlight is relative to $BUFFER.
+  (( start += buf_offset ))
+  (( end += buf_offset ))
 
-  # The calculation was relative to $PREBUFFER$BUFFER, but region_highlight is
-  # relative to $BUFFER.
-  (( start -= $#PREBUFFER ))
-  (( end -= $#PREBUFFER ))
+  list_highlights+=($start $end $1)
+}
 
-  (( end < 0 )) && return # having end<0 would be a bug
-  (( start < 0 )) && start=0 # having start<0 is normal with e.g. multiline strings
-  _zsh_highlight_add_highlight $start $end "$@"
+_zsh_highlight_main_add_many_region_highlights() {
+  for 1 2 3; do
+    _zsh_highlight_main_add_region_highlight $1 $2 $3
+  done
+}
+
+_zsh_highlight_main_calculate_fallback() {
+  local -A fallback_of; fallback_of=(
+      alias arg0
+      suffix-alias arg0
+      builtin arg0
+      function arg0
+      command arg0
+      precommand arg0
+      hashed-command arg0
+      arg0_\* arg0
+
+      path_prefix path
+      # The path separator fallback won't ever be used, due to the optimisation
+      # in _zsh_highlight_main_highlighter_highlight_path_separators().
+      path_pathseparator path
+      path_prefix_pathseparator path_prefix
+
+      single-quoted-argument{-unclosed,}
+      double-quoted-argument{-unclosed,}
+      dollar-quoted-argument{-unclosed,}
+      back-quoted-argument{-unclosed,}
+
+      command-substitution{-quoted,,-unquoted,}
+      command-substitution-delimiter{-quoted,,-unquoted,}
+
+      command-substitution{-delimiter,}
+      process-substitution{-delimiter,}
+      back-quoted-argument{-delimiter,}
+  )
+  local needle=$1 value
+  reply=($1)
+  while [[ -n ${value::=$fallback_of[(k)$needle]} ]]; do
+    unset "fallback_of[$needle]" # paranoia against infinite loops
+    reply+=($value)
+    needle=$value
+  done
 }
 
 # Get the type of a command.
@@ -108,24 +132,38 @@ _zsh_highlight_main_add_region_highlight() {
 # Uses the zsh/parameter module if available to avoid forks, and a
 # wrapper around 'type -w' as fallback.
 #
-# Takes a single argument.
+# If $2 is 0, do not consider aliases.
 #
 # The result will be stored in REPLY.
 _zsh_highlight_main__type() {
+  integer -r aliases_allowed=${2-1}
+  # We won't cache replies of anything that exists as an alias at all, to
+  # ensure the cached value is correct regardless of $aliases_allowed.
+  #
+  # ### We probably _should_ cache them in a cache that's keyed on the value of
+  # ### $aliases_allowed, on the assumption that aliases are the common case.
+  integer may_cache=1
+
+  # Cache lookup
   if (( $+_zsh_highlight_main__command_type_cache )); then
     REPLY=$_zsh_highlight_main__command_type_cache[(e)$1]
     if [[ -n "$REPLY" ]]; then
       return
     fi
   fi
+
+  # Main logic
   if (( $#options_to_set )); then
     setopt localoptions $options_to_set;
   fi
   unset REPLY
   if zmodload -e zsh/parameter; then
     if (( $+aliases[(e)$1] )); then
+      may_cache=0
+    fi
+    if (( $+aliases[(e)$1] )) && (( aliases_allowed )); then
       REPLY=alias
-    elif (( $+saliases[(e)${1##*.}] )); then
+    elif [[ $1 == *.* && -n ${1%.*} ]] && (( $+saliases[(e)${1##*.}] )); then
       REPLY='suffix alias'
     elif (( $reswords[(Ie)$1] )); then
       REPLY=reserved
@@ -147,11 +185,37 @@ _zsh_highlight_main__type() {
     fi
   fi
   if ! (( $+REPLY )); then
-    REPLY="${$(LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
+    # Note that 'type -w' will run 'rehash' implicitly.
+    #
+    # We 'unalias' in a subshell, so the parent shell is not affected.
+    #
+    # The colon command is there just to avoid a command substitution that
+    # starts with an arithmetic expression [«((…))» as the first thing inside
+    # «$(…)»], which is area that has had some parsing bugs before 5.6
+    # (approximately).
+    REPLY="${$(:; (( aliases_allowed )) || unalias -- $1 2>/dev/null; LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
+    if [[ $REPLY == 'alias' ]]; then
+      may_cache=0
+    fi
   fi
-  if (( $+_zsh_highlight_main__command_type_cache )); then
+
+  # Cache population
+  if (( may_cache )) && (( $+_zsh_highlight_main__command_type_cache )); then
     _zsh_highlight_main__command_type_cache[(e)$1]=$REPLY
   fi
+  [[ -n $REPLY ]]
+  return $?
+}
+
+# Checks whether $1 is something that can be run.
+#
+# Return 0 if runnable, 1 if not runnable, 2 if trouble.
+_zsh_highlight_main__is_runnable() {
+  if _zsh_highlight_main__type "$1"; then
+    [[ $REPLY != none ]]
+  else
+    return 2
+  fi
 }
 
 # Check whether the first argument is a redirection operator token.
@@ -161,7 +225,8 @@ _zsh_highlight_main__is_redirection() {
   # - starts with an optional single-digit number;
   # - then, has a '<' or '>' character;
   # - is not a process substitution [<(...) or >(...)].
-  [[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]]
+  # - is not a numeric glob <->
+  [[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]] && [[ $1 != *'<'*'-'*'>'* ]]
 }
 
 # Resolve alias.
@@ -181,40 +246,25 @@ _zsh_highlight_main__resolve_alias() {
 # the style according to $2; otherwise, set style=unknown-token.
 #
 # $1: character expected to be at the top of $braces_stack
-# $2: assignment to execute it if matches
+# $2: optional assignment to style it if matches
+# return value is 0 if there is a match else 1
 _zsh_highlight_main__stack_pop() {
   if [[ $braces_stack[1] == $1 ]]; then
     braces_stack=${braces_stack:1}
-    eval "$2"
+    if (( $+2 )); then
+      style=$2
+    fi
+    return 0
   else
     style=unknown-token
+    return 1
   fi
 }
 
 # Main syntax highlighting function.
 _zsh_highlight_highlighter_main_paint()
 {
-  ## Before we even 'emulate -L', we must test a few options that would reset.
-  if [[ -o interactive_comments ]]; then
-    local interactive_comments= # set to empty
-  fi
-  if [[ -o ignore_braces ]] || eval '[[ -o ignore_close_braces ]] 2>/dev/null'; then
-    local right_brace_is_recognised_everywhere=false
-  else
-    local right_brace_is_recognised_everywhere=true
-  fi
-  if [[ -o path_dirs ]]; then
-    integer path_dirs_was_set=1
-  else
-    integer path_dirs_was_set=0
-  fi
-  if [[ -o multi_func_def ]]; then
-    integer multi_func_def=1
-  else
-    integer multi_func_def=0
-  fi
-  emulate -L zsh
-  setopt localoptions extendedglob bareglobqual
+  setopt localoptions extendedglob
 
   # At the PS3 prompt and in vared, highlight nothing.
   #
@@ -225,30 +275,47 @@ _zsh_highlight_highlighter_main_paint()
     return
   fi
 
-  ## Variable declarations and initializations
-  local start_pos=0 end_pos highlight_glob=true arg style
-  local in_array_assignment=false # true between 'a=(' and the matching ')'
   typeset -a ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
-  typeset -a ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS
   typeset -a ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW
-  local -a options_to_set # used in callees
-  local buf="$PREBUFFER$BUFFER"
-  integer len="${#buf}"
-  integer pure_buf_len=$(( len - ${#PREBUFFER} ))   # == $#BUFFER, used e.g. in *_check_path
+  local -a options_to_set reply # used in callees
+  local REPLY
 
-  # "R" for round
-  # "Q" for square
-  # "Y" for curly
-  # "D" for do/done
-  # "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
-  # "?" for 'if'/'fi'; also checked by 'elif'/'else'
-  # ":" for 'then'
-  local braces_stack
+  # $flags_with_argument is a set of letters, corresponding to the option letters
+  # that would be followed by a colon in a getopts specification.
+  local flags_with_argument
+  # $flags_sans_argument is a set of letters, corresponding to the option letters
+  # that wouldn't be followed by a colon in a getopts specification.
+  local flags_sans_argument
+  # $precommand_options maps precommand name to values of $flags_with_argument and
+  # $flags_sans_argument for that precommand, joined by a colon.
+  #
+  # Currently, setting $flags_sans_argument is only important for commands that
+  # have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
+  local -A precommand_options
+  precommand_options=(
+    # Precommand modifiers as of zsh 5.6.2 cf. zshmisc(1).
+    '-' ''
+    'builtin' ''
+    'command' :pvV
+    'exec' a:cl
+    'nocorrect' ''
+    'noglob' ''
+
+    'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
+    'nice' n: # as of current POSIX spec
+    'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
+    'sudo' Cgprtu:AEHKPSVbhiklnsv # as of sudo 1.8.21p2
+  )
 
-  if (( path_dirs_was_set )); then
+  if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
+    local right_brace_is_recognised_everywhere=false
+  else
+    local right_brace_is_recognised_everywhere=true
+  fi
+
+  if [[ $zsyh_user_options[pathdirs] == on ]]; then
     options_to_set+=( PATH_DIRS )
   fi
-  unset path_dirs_was_set
 
   ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
     '|' '||' ';' '&' '&&'
@@ -257,10 +324,6 @@ _zsh_highlight_highlighter_main_paint()
     # ### 'case' syntax, but followed by a pattern, not by a command
     # ';;' ';&' ';|'
   )
-  ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS=(
-    'builtin' 'command' 'exec' 'nocorrect' 'noglob'
-    'pkexec' # immune to #121 because it's usually not passed --option flags
-  )
 
   # Tokens that, at (naively-determined) "command position", are followed by
   # a de jure command position.  All of these are reserved words.
@@ -280,14 +343,66 @@ _zsh_highlight_highlighter_main_paint()
     '!' # reserved word; unrelated to $histchars[1]
   )
 
-  local -a match mbegin mend
+  _zsh_highlight_main_highlighter_highlight_list -$#PREBUFFER '' 1 "$PREBUFFER$BUFFER"
+
+  # end is a reserved word
+  local start end_ style
+  for start end_ style in $reply; do
+    (( start >= end_ )) && { print -r -- >&2 "zsh-syntax-highlighting: BUG: _zsh_highlight_highlighter_main_paint: start($start) >= end($end_)"; return }
+    (( end_ <= 0 )) && continue
+    (( start < 0 )) && start=0 # having start<0 is normal with e.g. multiline strings
+    _zsh_highlight_main_calculate_fallback $style
+    _zsh_highlight_add_highlight $start $end_ $reply
+  done
+}
+
+# $1 is the offset of $4 from the parent buffer. Added to the returned highlights.
+# $2 is the initial braces_stack (for a closing paren).
+# $3 is 1 if $4 contains the end of $BUFFER, else 0.
+# $4 is the buffer to highlight.
+# Returns:
+# $REPLY: $buf[REPLY] is the last character parsed.
+# $reply is an array of region_highlight additions.
+# exit code is 0 if the braces_stack is empty, 1 otherwise.
+_zsh_highlight_main_highlighter_highlight_list()
+{
+  integer start_pos end_pos=0 buf_offset=$1 has_end=$3
+  # last_alias is the last alias arg (lhs) expanded (if in an alias).
+  #     This allows for expanding alias ls='ls -l' while avoiding loops.
+  local arg buf=$4 highlight_glob=true last_alias style
+  local in_array_assignment=false # true between 'a=(' and the matching ')'
+  # highlighted_alias is 1 when the alias arg has been highlighted with a non-alias style.
+  #     E.g. alias x=ls;  x has been highlighted as alias AND command.
+  # in_alias is equal to the number of shifts needed until arg=args[1] pops an
+  #     arg from BUFFER and not added by an alias.
+  integer highlighted_alias=0 in_alias=0 len=$#buf
+  local -a match mbegin mend list_highlights
+  # seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a
+  local -A seen_alias
+  # Pattern for parameter names
+  readonly parameter_name_pattern='([A-Za-z_][A-Za-z0-9_]*|[0-9]+)'
+  list_highlights=()
+
+  # "R" for round
+  # "Q" for square
+  # "Y" for curly
+  # "T" for [[ ]]
+  # "S" for $( )
+  # "D" for do/done
+  # "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
+  # "?" for 'if'/'fi'; also checked by 'elif'/'else'
+  # ":" for 'then'
+  local braces_stack=$2
 
   # State machine
   #
   # The states are:
   # - :start:      Command word
-  # - :sudo_opt:   A leading-dash option to sudo (such as "-u" or "-i")
-  # - :sudo_arg:   The argument to a sudo leading-dash option that takes one,
+  # - :start_of_pipeline:      Start of a 'pipeline' as defined in zshmisc(1).
+  #                Only valid when :start: is present
+  # - :sudo_opt:   A leading-dash option to a precommand, whether it takes an
+  #                argument or not.  (Example: sudo's "-u" or "-i".)
+  # - :sudo_arg:   The argument to a precommand's leading-dash option,
   #                when given as a separate word; i.e., "foo" in "-u foo" (two
   #                words) but not in "-ufoo" (one word).
   # - :regular:    "Not a command word", and command delimiters are permitted.
@@ -300,7 +415,7 @@ _zsh_highlight_highlighter_main_paint()
   # and :sudo_opt:.
   #
   # The tokens are always added with both leading and trailing colons to serve as
-  # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/} 
+  # word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/}
   # will DTRT regardless of how many elements or repetitions $x has..
   #
   # Handling of redirections: upon seeing a redirection token, we must stall
@@ -318,35 +433,39 @@ _zsh_highlight_highlighter_main_paint()
   # $in_redirection.  The value of $next_word from the iteration that processed
   # the operator is discarded.
   #
-  local this_word=':start:' next_word
+  local this_word next_word=':start::start_of_pipeline:'
   integer in_redirection
   # Processing buffer
   local proc_buf="$buf"
-  for arg in ${interactive_comments-${(z)buf}} \
-             ${interactive_comments+${(zZ+c+)buf}}; do
-    # Initialize $next_word.
-    if (( in_redirection )); then
-      (( --in_redirection ))
+  local -a args
+  if [[ $zsyh_user_options[interactivecomments] == on ]]; then
+    args=(${(zZ+c+)buf})
+  else
+    args=(${(z)buf})
+  fi
+  while (( $#args )); do
+    arg=$args[1]
+    shift args
+    if (( in_alias )); then
+      (( in_alias-- ))
+      (( in_alias == 0 )) && highlighted_alias=0 last_alias= seen_alias=()
     fi
+
+    # Initialize this_word and next_word.
     if (( in_redirection == 0 )); then
-      # Initialize $next_word to its default value.
+      this_word=$next_word
       next_word=':regular:'
     else
       # Stall $next_word.
+      (( --in_redirection ))
     fi
 
     # Initialize per-"simple command" [zshmisc(1)] variables:
     #
-    #   $already_added       (see next paragraph)
     #   $style               how to highlight $arg
     #   $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
     #   $highlight_glob      boolean flag for "'noglob' is in effect"
     #
-    # $already_added is set to 1 to disable adding an entry to region_highlight
-    # for this iteration.  Currently, that is done for "" and $'' strings,
-    # which add the entry early so escape sequences within the string override
-    # the string's color.
-    integer already_added=0
     style=unknown-token
     if [[ $this_word == *':start:'* ]]; then
       in_array_assignment=false
@@ -355,101 +474,177 @@ _zsh_highlight_highlighter_main_paint()
       fi
     fi
 
-    # Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
-    if [[ $arg == ';' ]] ; then
-      # We're looking for either a semicolon or a newline, whichever comes
-      # first.  Both of these are rendered as a ";" (SEPER) by the ${(z)..}
-      # flag.
-      #
-      # We can't use the (Z+n+) flag because that elides the end-of-command
-      # token altogether, so 'echo foo\necho bar' (two commands) becomes
-      # indistinguishable from 'echo foo echo bar' (one command with three
-      # words for arguments).
-      local needle=$'[;\n]'
-      integer offset=$(( ${proc_buf[(i)$needle]} - 1 ))
-      (( start_pos += offset ))
+    if (( in_alias == 0 )); then
+      # Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
+      [[ "$proc_buf" = (#b)(#s)(([ $'\t']|\\$'\n')#)* ]]
+      # The first, outer parenthesis
+      integer offset="${#match[1]}"
+      (( start_pos = end_pos + offset ))
       (( end_pos = start_pos + $#arg ))
-    else
-      # The line was:
+
+      # Compute the new $proc_buf. We advance it
+      # (chop off characters from the beginning)
+      # beyond what end_pos points to, by skipping
+      # as many characters as end_pos was advanced.
       #
-      # integer offset=$(((len-start_pos)-${#${proc_buf##([[:space:]]|\\[[:space:]])#}}))
+      # end_pos was advanced by $offset (via start_pos)
+      # and by $#arg. Note the `start_pos=$end_pos`
+      # below.
       #
-      # - len-start_pos is length of current proc_buf; basically: initial length minus where
-      #   we are, and proc_buf is chopped to the "where we are" (compare the "previous value
-      #   of start_pos" below, and the len-(start_pos-offset) = len-start_pos+offset)
-      # - what's after main minus sign is: length of proc_buf without spaces at the beginning
-      # - so what the line actually did, was computing length of the spaces!
-      # - this can be done via (#b) flag, like below
-      if [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\[[:space:]])##)* ]]; then
-          # The first, outer parenthesis
-          integer offset="${#match[1]}"
-      else
-          integer offset=0
-      fi
-      ((start_pos+=offset))
-      ((end_pos=$start_pos+${#arg}))
+      # As for the [,len]. We could use [,len-start_pos+offset]
+      # here, but to make it easier on eyes, we use len and
+      # rely on the fact that Zsh simply handles that. The
+      # length of proc_buf is len-start_pos+offset because
+      # we're chopping it to match current start_pos, so its
+      # length matches the previous value of start_pos.
+      #
+      # Why [,-1] is slower than [,length] isn't clear.
+      proc_buf="${proc_buf[offset + $#arg + 1,len]}"
     fi
 
-    # Compute the new $proc_buf. We advance it
-    # (chop off characters from the beginning)
-    # beyond what end_pos points to, by skipping
-    # as many characters as end_pos was advanced.
-    #
-    # end_pos was advanced by $offset (via start_pos)
-    # and by $#arg. Note the `start_pos=$end_pos`
-    # below.
-    #
-    # As for the [,len]. We could use [,len-start_pos+offset]
-    # here, but to make it easier on eyes, we use len and
-    # rely on the fact that Zsh simply handles that. The
-    # length of proc_buf is len-start_pos+offset because
-    # we're chopping it to match current start_pos, so its
-    # length matches the previous value of start_pos.
-    #
-    # Why [,-1] is slower than [,length] isn't clear.
-    proc_buf="${proc_buf[offset + $#arg + 1,len]}"
-
     # Handle the INTERACTIVE_COMMENTS option.
     #
     # We use the (Z+c+) flag so the entire comment is presented as one token in $arg.
-    if [[ -n ${interactive_comments+'set'} && $arg[1] == $histchars[3] ]]; then
+    if [[ $zsyh_user_options[interactivecomments] == on && $arg[1] == $histchars[3] ]]; then
       if [[ $this_word == *(':regular:'|':start:')* ]]; then
         style=comment
       else
         style=unknown-token # prematurely terminated
       fi
       _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
-      already_added=1
-      start_pos=$end_pos
+      # Stall this arg
+      in_redirection=1
       continue
     fi
 
+    if [[ $this_word == *:start:* ]] && ! (( in_redirection )); then
+      # Expand aliases.
+      _zsh_highlight_main__type "$arg"
+      local res="$REPLY"
+      if [[ $res == "alias" ]] && [[ $last_alias != $arg ]]; then
+        # Avoid looping forever on alias a=b b=c c=b, but allow alias foo='foo bar'
+        # Also mark insane aliases as unknown-token (cf. #263).
+        if (( $+seen_alias[$arg] )) || [[ $arg == ?*=* ]]; then
+          _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
+          continue
+        fi
+        seen_alias[$arg]=1
+        last_alias=$arg
+        _zsh_highlight_main__resolve_alias $arg
+        local -a alias_args
+        # Elision is desired in case alias x=''
+        alias_args=( ${interactive_comments-${(z)REPLY}}
+                     ${interactive_comments+${(zZ+c+)REPLY}} )
+        args=( $alias_args $args )
+        if (( in_alias == 0 )); then
+          _zsh_highlight_main_add_region_highlight $start_pos $end_pos alias
+          # Add one because we will in_alias-- on the next loop iteration so
+          # this iteration should be considered in in_alias as well
+          (( in_alias += $#alias_args + 1 ))
+        else
+          # This arg is already included in the count, so no need to + 1.
+          (( in_alias += $#alias_args ))
+        fi
+        (( in_redirection++ )) # Stall this arg
+        continue
+      else
+        _zsh_highlight_main_highlighter_expand_path $arg
+        arg=$REPLY
+        _zsh_highlight_main__type "$arg" 0
+        res="$REPLY"
+      fi
+    fi
+
     # Analyse the current word.
     if _zsh_highlight_main__is_redirection $arg ; then
-      # A '<' or '>', possibly followed by a digit
-      in_redirection=2
+      if (( in_redirection == 1 )); then
+        # The condition excludes the case that BUFFER='{foo}>&2' and we're on the '>&'.
+        _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
+      else
+        in_redirection=2
+        _zsh_highlight_main_add_region_highlight $start_pos $end_pos redirection
+      fi
+      continue
+    elif [[ $arg == '{'${~parameter_name_pattern}'}' ]] && _zsh_highlight_main__is_redirection $args[1]; then
+      # named file descriptor: {foo}>&2
+      in_redirection=3
+      _zsh_highlight_main_add_region_highlight $start_pos $end_pos named-fd
+      continue
     fi
 
-    # Special-case the first word after 'sudo'.
-    if (( ! in_redirection )); then
-      if [[ $this_word == *':sudo_opt:'* ]] && [[ $arg != -* ]]; then
-        this_word=${this_word//:sudo_opt:/}
+    # Expand parameters.
+    #
+    # ### For now, expand just '$foo' or '${foo}', possibly with braces, but with
+    # ### no other features of the parameter expansion syntax.  (No ${(x)foo},
+    # ### no ${foo[x]}, no ${foo:-x}.)
+    () {
+      # That's not entirely correct --- if the parameter's value happens to be a reserved
+      # word, the parameter expansion will be highlighted as a reserved word --- but that
+      # incorrectness is outweighed by the usability improvement of permitting the use of
+      # parameters that refer to commands, functions, and builtins.
+      local -a match mbegin mend
+      local MATCH; integer MBEGIN MEND
+      local parameter_name
+      if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
+        parameter_name=${${arg:2}%?}
+      elif [[ $arg[1] == '$' ]]; then
+        parameter_name=${arg:1}
       fi
-    fi
+      if [[ $res == none ]] && zmodload -e zsh/parameter &&
+         [[ ${parameter_name} =~ ^${~parameter_name_pattern}$ ]] &&
+         (( ${+parameters[(e)${MATCH}]} )) && [[ ${parameters[(e)$MATCH]} != *special* ]]
+         then
+        # Set $arg.
+        case ${(tP)MATCH} in
+          (*array*|*assoc*)
+            local -a words; words=( ${(P)MATCH} )
+            arg=${words[1]}
+            ;;
+          (*)
+            # scalar, presumably
+            arg=${(P)MATCH}
+            ;;
+        esac
+        _zsh_highlight_main__type "$arg" 0
+        res=$REPLY
+      fi
+    }
 
     # Parse the sudo command line
     if (( ! in_redirection )); then
       if [[ $this_word == *':sudo_opt:'* ]]; then
-        case "$arg" in
+        if [[ -n $flags_with_argument ]] &&
+           { [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] ||
+             [[ $arg == '-'[$flags_with_argument] ]] }; then
           # Flag that requires an argument
-          '-'[Cgprtu]) this_word=${this_word//:start:/};
-                       next_word=':sudo_arg:';;
-          # This prevents misbehavior with sudo -u -otherargument
-          '-'*)        this_word=${this_word//:start:/};
-                       next_word+=':start:';
-                       next_word+=':sudo_opt:';;
-          *)           ;;
-        esac
+          this_word=${this_word//:start:/}
+          next_word=':sudo_arg:'
+        elif [[ -n $flags_with_argument ]] &&
+             { [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] ||
+               [[ $arg == '-'[$flags_with_argument]* ]] }; then
+          # Argument attached in the same word
+          this_word=${this_word//:start:/}
+          next_word+=':start:'
+          next_word+=':sudo_opt:'
+        elif [[ -n $flags_sans_argument ]] &&
+             [[ $arg == '-'[$flags_sans_argument]# ]]; then
+          # Flag that requires no argument
+          this_word=:sudo_opt:
+          next_word+=':start:'
+          next_word+=':sudo_opt:'
+        elif [[ $arg == '-'* ]]; then
+          # Unknown flag
+          this_word=:sudo_opt:
+          next_word+=':start:'
+          next_word+=':sudo_opt:'
+          _zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
+          continue
+        else
+          # Not an option flag; nothing to do.  (If the command line is
+          # syntactically valid, ${this_word//:sudo_opt:/} should be
+          # non-empty now.)
+          this_word=${this_word//:sudo_opt:/}
+        fi
       elif [[ $this_word == *':sudo_arg:'* ]]; then
         next_word+=':sudo_opt:'
         next_word+=':start:'
@@ -457,65 +652,69 @@ _zsh_highlight_highlighter_main_paint()
    fi
 
    # The Great Fork: is this a command word?  Is this a non-command word?
-   if [[ $this_word == *':always:'* && $arg == 'always' ]]; then
+   if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
+     if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
+       # Missing closing square bracket(s)
+       style=unknown-token
+     elif [[ $this_word == *':regular:'* ]]; then
+       # This highlights empty commands (semicolon follows nothing) as an error.
+       # Zsh accepts them, though.
+       style=commandseparator
+     else
+       style=unknown-token
+     fi
+     if [[ $arg == ';' ]] && $in_array_assignment; then
+       # literal newline inside an array assignment
+       next_word=':regular:'
+     else
+       next_word=':start:'
+       highlight_glob=true
+       if [[ $arg != '|' && $arg != '|&' ]]; then
+         next_word+=':start_of_pipeline:'
+       fi
+     fi
+   elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
      # try-always construct
      style=reserved-word # de facto a reserved word, although not de jure
-     next_word=':start:'
-   elif [[ $this_word == *':start:'* ]] && (( in_redirection == 0 )); then # $arg is the command word
-     if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]]; then
-      style=precommand
-     elif [[ "$arg" = "sudo" ]]; then
+     next_word=':start:' # only left brace is allowed, apparently
+   elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
+     if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
       style=precommand
+      flags_with_argument=${precommand_options[$arg]%:*}
+      flags_sans_argument=${precommand_options[$arg]#*:}
       next_word=${next_word//:regular:/}
       next_word+=':sudo_opt:'
       next_word+=':start:'
      else
-      _zsh_highlight_main_highlighter_expand_path $arg
-      local expanded_arg="$REPLY"
-      _zsh_highlight_main__type ${expanded_arg}
-      local res="$REPLY"
-      () {
-        # Special-case: command word is '$foo', like that, without braces or anything.
-        #
-        # That's not entirely correct --- if the parameter's value happens to be a reserved
-        # word, the parameter expansion will be highlighted as a reserved word --- but that
-        # incorrectness is outweighed by the usability improvement of permitting the use of
-        # parameters that refer to commands, functions, and builtins.
-        local -a match mbegin mend
-        local MATCH; integer MBEGIN MEND
-        if [[ $res == none ]] && (( ${+parameters} )) &&
-           [[ ${arg[1]} == \$ ]] && [[ ${arg:1} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+)$ ]] &&
-           (( ${+parameters[${MATCH}]} ))
-           then
-          _zsh_highlight_main__type ${(P)MATCH}
-          res=$REPLY
-        fi
-      }
       case $res in
         reserved)       # reserved word
                         style=reserved-word
+                        # Match braces and handle special cases.
                         case $arg in
                           ($'\x7b')
                             braces_stack='Y'"$braces_stack"
                             ;;
                           ($'\x7d')
                             # We're at command word, so no need to check $right_brace_is_recognised_everywhere
-                            _zsh_highlight_main__stack_pop 'Y' style=reserved-word
+                            _zsh_highlight_main__stack_pop 'Y' reserved-word
                             if [[ $style == reserved-word ]]; then
                               next_word+=':always:'
                             fi
                             ;;
+                          ($'\x5b\x5b')
+                            braces_stack='T'"$braces_stack"
+                            ;;
                           ('do')
                             braces_stack='D'"$braces_stack"
                             ;;
                           ('done')
-                            _zsh_highlight_main__stack_pop 'D' style=reserved-word
+                            _zsh_highlight_main__stack_pop 'D' reserved-word
                             ;;
                           ('if')
                             braces_stack=':?'"$braces_stack"
                             ;;
                           ('then')
-                            _zsh_highlight_main__stack_pop ':' style=reserved-word
+                            _zsh_highlight_main__stack_pop ':' reserved-word
                             ;;
                           ('elif')
                             if [[ ${braces_stack[1]} == '?' ]]; then
@@ -532,68 +731,68 @@ _zsh_highlight_highlighter_main_paint()
                             fi
                             ;;
                           ('fi')
-                            _zsh_highlight_main__stack_pop '?' ""
+                            _zsh_highlight_main__stack_pop '?'
                             ;;
                           ('foreach')
                             braces_stack='$'"$braces_stack"
                             ;;
                           ('end')
-                            _zsh_highlight_main__stack_pop '$' style=reserved-word
+                            _zsh_highlight_main__stack_pop '$' reserved-word
+                            ;;
+                          ('repeat')
+                            # skip the repeat-count word
+                            in_redirection=2
+                            # The redirection mechanism assumes $this_word describes the word
+                            # following the redirection.  Make it so.
+                            #
+                            # That word can be a command word with shortloops (`repeat 2 ls`)
+                            # or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`).
+                            #
+                            # The repeat-count word will be handled like a redirection target.
+                            this_word=':start::regular:'
+                            ;;
+                          ('!')
+                            if [[ $this_word != *':start_of_pipeline:'* ]]; then
+                              style=unknown-token
+                            else
+                              # '!' reserved word at start of pipeline; style already set above
+                            fi
                             ;;
                         esac
                         ;;
         'suffix alias') style=suffix-alias;;
-        alias)          () {
-                          integer insane_alias
-                          case $arg in 
-                            # Issue #263: aliases with '=' on their LHS.
-                            #
-                            # There are three cases:
-                            #
-                            # - Unsupported, breaks 'alias -L' output, but invokable:
-                            ('='*) :;;
-                            # - Unsupported, not invokable:
-                            (*'='*) insane_alias=1;;
-                            # - The common case:
-                            (*) :;;
-                          esac
-                          if (( insane_alias )); then
-                            style=unknown-token
-                          else
-                            style=alias
-                            _zsh_highlight_main__resolve_alias $arg
-                            local alias_target="$REPLY"
-                            [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$alias_target"} && -z ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} ]] && ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS+=($arg)
-                          fi
-                        }
+        alias)          :;;
+        builtin)        style=builtin
+                        [[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack"
                         ;;
-        builtin)        style=builtin;;
         function)       style=function;;
         command)        style=command;;
         hashed)         style=hashed-command;;
         none)           if _zsh_highlight_main_highlighter_check_assign; then
-                          style=assign
-                          if [[ $arg[-1] == '(' ]]; then
+                          _zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
+                          local i=$(( arg[(i)=] + 1 ))
+                          if [[ $arg[i] == '(' ]]; then
                             in_array_assignment=true
                           else
                             # assignment to a scalar parameter.
                             # (For array assignments, the command doesn't start until the ")" token.)
+                            # 
+                            # Discard  :start_of_pipeline:, if present, as '!' is not valid
+                            # after assignments.
                             next_word+=':start:'
+                            if (( start_pos + i <= end_pos )); then
+                              () {
+                                local highlight_glob=false
+                                [[ $zsyh_user_options[globassign] == on ]] && highlight_glob=true
+                                _zsh_highlight_main_highlighter_highlight_argument $i
+                              }
+                            fi
                           fi
+                          continue
                         elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
                           style=history-expansion
                         elif [[ $arg[0,1] == $histchars[2,2] ]]; then
                           style=history-expansion
-                        elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
-                          if [[ $this_word == *':regular:'* ]]; then
-                            # This highlights empty commands (semicolon follows nothing) as an error.
-                            # Zsh accepts them, though.
-                            style=commandseparator
-                          else
-                            style=unknown-token
-                          fi
-                        elif (( in_redirection == 2 )); then
-                          style=redirection
                         elif [[ $arg[1,2] == '((' ]]; then
                           # Arithmetic evaluation.
                           #
@@ -604,13 +803,11 @@ _zsh_highlight_highlighter_main_paint()
                           #
                           # We highlight just the opening parentheses, as a reserved word; this
                           # is how [[ ... ]] is highlighted, too.
-                          style=reserved-word
-                          _zsh_highlight_main_add_region_highlight $start_pos $((start_pos + 2)) $style
-                          already_added=1
+                          _zsh_highlight_main_add_region_highlight $start_pos $((start_pos + 2)) reserved-word
                           if [[ $arg[-2,-1] == '))' ]]; then
-                            _zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos $style
-                            already_added=1
+                            _zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
                           fi
+                          continue
                         elif [[ $arg == '()' ]]; then
                           # anonymous function
                           style=reserved-word
@@ -619,132 +816,90 @@ _zsh_highlight_highlighter_main_paint()
                           style=reserved-word
                           braces_stack='R'"$braces_stack"
                         elif [[ $arg == $'\x29' ]]; then
-                          # end of subshell
-                          _zsh_highlight_main__stack_pop 'R' style=reserved-word
+                          # end of subshell or command substitution
+                          if _zsh_highlight_main__stack_pop 'S'; then
+                            REPLY=$start_pos
+                            reply=($list_highlights)
+                            return 0
+                          fi
+                          _zsh_highlight_main__stack_pop 'R' reserved-word
                         else
-                          if _zsh_highlight_main_highlighter_check_path; then
+                          if _zsh_highlight_main_highlighter_check_path $arg; then
                             style=$REPLY
                           else
                             style=unknown-token
                           fi
                         fi
                         ;;
-        *)              _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res arg0
-                        already_added=1
+        *)              _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
+                        continue
                         ;;
       esac
      fi
-   fi
-   if (( ! already_added )) && [[ $style == unknown-token ]] && # not handled by the 'command word' codepath
-      { (( in_redirection )) || [[ $this_word == *':regular:'* ]] || [[ $this_word == *':sudo_opt:'* ]] || [[ $this_word == *':sudo_arg:'* ]] }
-   then # $arg is a non-command word
+     if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
+      next_word=':start::start_of_pipeline:'
+     fi
+   else # $arg is a non-command word
       case $arg in
         $'\x29') # subshell or end of array assignment
                  if $in_array_assignment; then
                    style=assign
                    in_array_assignment=false
                    next_word+=':start:'
+                 elif (( in_redirection )); then
+                   style=unknown-token
                  else
-                   _zsh_highlight_main__stack_pop 'R' style=reserved-word
+                   if _zsh_highlight_main__stack_pop 'S'; then
+                     REPLY=$start_pos
+                     reply=($list_highlights)
+                     return 0
+                   fi
+                   _zsh_highlight_main__stack_pop 'R' reserved-word
                  fi;;
         $'\x28\x29') # possibly a function definition
-                 if (( multi_func_def )) || false # TODO: or if the previous word was a command word
-                 then
-                   next_word+=':start:'
-                 fi
-                 style=reserved-word
-                 ;;
-        $'\x7d') # right brace
-                 #
-                 # Parsing rule: # {
-                 #
-                 #     Additionally, `tt(})' is recognized in any position if neither the
-                 #     tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set."""
-                 if $right_brace_is_recognised_everywhere; then
-                   _zsh_highlight_main__stack_pop 'Y' style=reserved-word
-                   if [[ $style == reserved-word ]]; then
-                     next_word+=':always:'
-                   fi
+                 if (( in_redirection )) || $in_array_assignment; then
+                   style=unknown-token
                  else
-                   # Fall through to the catchall case at the end.
+                   if [[ $zsyh_user_options[multifuncdef] == on ]] || false # TODO: or if the previous word was a command word
+                   then
+                     next_word+=':start::start_of_pipeline:'
+                   fi
+                   style=reserved-word
                  fi
-                 ;|
-        '--'*)   style=double-hyphen-option;;
-        '-'*)    style=single-hyphen-option;;
-        "'"*)    style=single-quoted-argument;;
-        '"'*)    style=double-quoted-argument
-                 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
-                 _zsh_highlight_main_highlighter_highlight_string
-                 already_added=1
-                 ;;
-        \$\'*)   style=dollar-quoted-argument
-                 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
-                 _zsh_highlight_main_highlighter_highlight_dollar_string
-                 already_added=1
                  ;;
-        '`'*)    style=back-quoted-argument;;
-        [$][*])  style=default;;
-        [*?]*|*[^\\][*?]*)
-                 $highlight_glob && style=globbing || style=default;;
         *)       if false; then
                  elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
-                   # was handled by the $'\x7d' case above
-                 elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
-                   style=history-expansion
-                 elif [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
-                   if [[ $this_word == *':regular:'* ]]; then
-                     style=commandseparator
-                   else
+                   # Parsing rule: {
+                   #
+                   #     Additionally, `tt(})' is recognized in any position if neither the
+                   #     tt(IGNORE_BRACES) option nor the tt(IGNORE_CLOSE_BRACES) option is set.
+                   if (( in_redirection )) || $in_array_assignment; then
                      style=unknown-token
-                   fi
-                 elif (( in_redirection == 2 )); then
-                   style=redirection
-                 else
-                   if _zsh_highlight_main_highlighter_check_path; then
-                     style=$REPLY
                    else
-                     style=default
+                     _zsh_highlight_main__stack_pop 'Y' reserved-word
+                     if [[ $style == reserved-word ]]; then
+                       next_word+=':always:'
+                     fi
                    fi
+                 elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
+                   style=history-expansion
+                 elif [[ $arg == $'\x5d\x5d' ]] && _zsh_highlight_main__stack_pop 'T' reserved-word; then
+                   :
+                 elif [[ $arg == $'\x5d' ]] && _zsh_highlight_main__stack_pop 'Q' builtin; then
+                   :
+                 else
+                   _zsh_highlight_main_highlighter_highlight_argument 1 $(( 1 != in_redirection ))
+                   continue
                  fi
                  ;;
       esac
     fi
-    if ! (( already_added )); then
-      _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
-      [[ $style == path || $style == path_prefix ]] && _zsh_highlight_main_highlighter_highlight_path_separators
-    fi
-    if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
-      if [[ $arg == ';' ]] && $in_array_assignment; then
-        # literal newline inside an array assignment
-        next_word=':regular:'
-      else
-        next_word=':start:'
-        highlight_glob=true
-      fi
-    elif
-       [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} && $this_word == *':start:'* ]] ||
-       [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_PRECOMMANDS:#"$arg"} && $this_word == *':start:'* ]]; then
-      next_word=':start:'
-    elif [[ $arg == "repeat" && $this_word == *':start:'* ]]; then
-      # skip the repeat-count word
-      in_redirection=2
-      # The redirection mechanism assumes $this_word describes the word
-      # following the redirection.  Make it so.
-      #
-      # That word can be a command word with shortloops (`repeat 2 ls`)
-      # or a command separator (`repeat 2; ls` or `repeat 2; do ls; done`).
-      #
-      # The repeat-count word will be handled like a redirection target.
-      this_word=':start::regular:'
-    fi
-    start_pos=$end_pos
-    if (( in_redirection == 0 )); then
-      # This is the default/common codepath.
-      this_word=$next_word
-    else
-      # Stall $this_word.
-    fi
+    _zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
   done
+  [[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
+  REPLY=$(( end_pos + ${#match[1]} - 1 ))
+  reply=($list_highlights)
+  return $(( $#braces_stack > 0 ))
 }
 
 # Check if $arg is variable assignment
@@ -758,26 +913,41 @@ _zsh_highlight_main_highlighter_check_assign()
 _zsh_highlight_main_highlighter_highlight_path_separators()
 {
   local pos style_pathsep
-  style_pathsep=${style}_pathseparator
-  [[ -z "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" || "$ZSH_HIGHLIGHT_STYLES[$style]" == "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" ]] && return 0
+  style_pathsep=$1_pathseparator
+  reply=()
+  [[ -z "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" || "$ZSH_HIGHLIGHT_STYLES[$1]" == "$ZSH_HIGHLIGHT_STYLES[$style_pathsep]" ]] && return 0
   for (( pos = start_pos; $pos <= end_pos; pos++ )) ; do
     if [[ $BUFFER[pos] == / ]]; then
-      _zsh_highlight_main_add_region_highlight $((pos - 1)) $pos $style_pathsep
+      reply+=($((pos - 1)) $pos $style_pathsep)
     fi
   done
 }
 
-# Check if $arg is a path.
+# Check if $1 is a path.
 # If yes, return 0 and in $REPLY the style to use.
 # Else, return non-zero (and the contents of $REPLY is undefined).
 _zsh_highlight_main_highlighter_check_path()
 {
-  _zsh_highlight_main_highlighter_expand_path $arg;
-  local expanded_path="$REPLY"
+  _zsh_highlight_main_highlighter_expand_path "$1"
+  local expanded_path="$REPLY" tmp_path
 
   REPLY=path
 
   [[ -z $expanded_path ]] && return 1
+
+  # Check if this is a blacklisted path
+  if [[ $expanded_path[1] == / ]]; then
+    tmp_path=$expanded_path
+  else
+    tmp_path=$PWD/$expanded_path
+  fi
+  tmp_path=$tmp_path:a
+
+  while [[ $tmp_path != / ]]; do
+    [[ -n ${(M)X_ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1
+    tmp_path=$tmp_path:h
+  done
+
   [[ -L $expanded_path ]] && return 0
   [[ -e $expanded_path ]] && return 0
 
@@ -787,11 +957,11 @@ _zsh_highlight_main_highlighter_check_path()
     [[ -e "$cdpath_dir/$expanded_path" ]] && return 0
   done
 
-  # If dirname($arg) doesn't exist, neither does $arg.
+  # If dirname($1) doesn't exist, neither does $1.
   [[ ! -d ${expanded_path:h} ]] && return 1
 
   # If this word ends the buffer, check if it's the prefix of a valid path.
-  if [[ ${BUFFER[1]} != "-" && $pure_buf_len == $end_pos ]] &&
+  if (( has_end && (len == end_pos) )) &&
      [[ $WIDGET != zle-line-finish ]]; then
     local -a tmp
     tmp=( ${expanded_path}*(N) )
@@ -802,18 +972,186 @@ _zsh_highlight_main_highlighter_check_path()
   return 1
 }
 
-# Highlight special chars inside double-quoted strings
-_zsh_highlight_main_highlighter_highlight_string()
+# Highlight an argument and possibly special chars in quotes starting at $1 in $arg
+# This command will at least highlight $1 to end_pos with the default style
+# If $2 is set to 0, the argument cannot be highlighted as an option.
+_zsh_highlight_main_highlighter_highlight_argument()
 {
-  setopt localoptions noksharrays
+  local base_style=default i=$1 option_eligible=${2:-1} path_eligible=1 ret start style
+  local -a highlights
+
   local -a match mbegin mend
   local MATCH; integer MBEGIN MEND
-  local i j k style
-  # Starting quote is at 1, so start parsing at offset 2 in the string.
-  for (( i = 2 ; i < end_pos - start_pos ; i += 1 )) ; do
+
+  case "$arg[i]" in
+    '-')
+      if (( option_eligible )); then
+        if [[ $arg[i+1] == - ]]; then
+          base_style=double-hyphen-option
+        else
+          base_style=single-hyphen-option
+        fi
+        path_eligible=0
+      fi
+      ;;
+    '=')
+      if [[ $arg[i+1] == $'\x28' ]]; then
+        (( i += 2 ))
+        _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
+        ret=$?
+        (( i += REPLY ))
+        highlights+=(
+          $(( start_pos + $1 - 1 )) $(( start_pos + i )) process-substitution
+          $(( start_pos + $1 - 1 )) $(( start_pos + $1 + 1 )) process-substitution-delimiter
+          $reply
+        )
+        if (( ret == 0 )); then
+          highlights+=($(( start_pos + i - 1 )) $(( start_pos + i )) process-substitution-delimiter)
+        fi
+      fi
+  esac
+
+  for (( ; i <= end_pos - start_pos ; i += 1 )); do
+    case "$arg[$i]" in
+      "\\") (( i += 1 )); continue;;
+      "'")
+        _zsh_highlight_main_highlighter_highlight_single_quote $i
+        (( i = REPLY ))
+        highlights+=($reply)
+        ;;
+      '"')
+        _zsh_highlight_main_highlighter_highlight_double_quote $i
+        (( i = REPLY ))
+        highlights+=($reply)
+        ;;
+      '`')
+        _zsh_highlight_main_highlighter_highlight_backtick $i
+        (( i = REPLY ))
+        highlights+=($reply)
+        ;;
+      '$')
+        path_eligible=0
+        if [[ $arg[i+1] == "'" ]]; then
+          path_eligible=1
+          _zsh_highlight_main_highlighter_highlight_dollar_quote $i
+          (( i = REPLY ))
+          highlights+=($reply)
+          continue
+       elif [[ $arg[i+1] == $'\x28' ]]; then
+          start=$i
+          (( i += 2 ))
+          _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
+          ret=$?
+          (( i += REPLY ))
+          highlights+=(
+            $(( start_pos + start - 1)) $(( start_pos + i )) command-substitution-unquoted
+            $(( start_pos + start - 1)) $(( start_pos + start + 1)) command-substitution-delimiter-unquoted
+            $reply
+          )
+          if (( ret == 0 )); then
+            highlights+=($(( start_pos + i - 1)) $(( start_pos + i )) command-substitution-delimiter-unquoted)
+          fi
+          continue
+        fi
+        while [[ $arg[i+1] == [\^=~#+] ]]; do
+          (( i += 1 ))
+        done
+        if [[ $arg[i+1] == [*@#?$!-] ]]; then
+          (( i += 1 ))
+        fi;;
+      [\<\>])
+        if [[ $arg[i+1] == $'\x28' ]]; then # \x28 = open paren
+          start=$i
+          (( i += 2 ))
+          _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
+          ret=$?
+          (( i += REPLY ))
+          highlights+=(
+            $(( start_pos + start - 1)) $(( start_pos + i )) process-substitution
+            $(( start_pos + start - 1)) $(( start_pos + start + 1 )) process-substitution-delimiter
+            $reply
+          )
+          if (( ret == 0 )); then
+            highlights+=($(( start_pos + i - 1)) $(( start_pos + i )) process-substitution-delimiter)
+          fi
+          continue
+        fi
+        ;|
+      *)
+        if $highlight_glob && [[ ${arg[$i]} =~ ^[*?] || ${arg:$i-1} =~ ^\<[0-9]*-[0-9]*\> ]]; then
+          highlights+=($(( start_pos + i - 1 )) $(( start_pos + i + $#MATCH - 1)) globbing)
+          (( i += $#MATCH - 1 ))
+          path_eligible=0
+        else
+          continue
+        fi
+        ;;
+    esac
+  done
+
+  if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path $arg[$1,end_pos]; then
+    base_style=$REPLY
+    _zsh_highlight_main_highlighter_highlight_path_separators $base_style
+    highlights+=($reply)
+  fi
+
+  highlights=($(( start_pos + $1 - 1 )) $end_pos $base_style $highlights)
+  _zsh_highlight_main_add_many_region_highlights $highlights
+}
+
+# Quote Helper Functions
+#
+# $arg is expected to be set to the current argument
+# $start_pos is expected to be set to the start of $arg in $BUFFER
+# $1 is the index in $arg which starts the quote
+# $REPLY is returned as the end of quote index in $arg
+# $reply is returned as an array of region_highlight additions
+
+# Highlight single-quoted strings
+_zsh_highlight_main_highlighter_highlight_single_quote()
+{
+  local arg1=$1 i q=\' style
+  i=$arg[(ib:arg1+1:)$q]
+  reply=()
+
+  if [[ $zsyh_user_options[rcquotes] == on ]]; then
+    while [[ $arg[i+1] == "'" ]]; do
+      reply+=($(( start_pos + i - 1 )) $(( start_pos + i + 1 )) rc-quote)
+      (( i++ ))
+      i=$arg[(ib:i+1:)$q]
+    done
+  fi
+
+  if [[ $arg[i] == "'" ]]; then
+    style=single-quoted-argument
+  else
+    # If unclosed, i points past the end
+    (( i-- ))
+    style=single-quoted-argument-unclosed
+  fi
+  reply=($(( start_pos + arg1 - 1 )) $(( start_pos + i )) $style $reply)
+  REPLY=$i
+}
+
+# Highlight special chars inside double-quoted strings
+_zsh_highlight_main_highlighter_highlight_double_quote()
+{
+  local -a breaks match mbegin mend saved_reply
+  local MATCH; integer last_break=$(( start_pos + $1 - 1 )) MBEGIN MEND
+  local i j k ret style
+  reply=()
+
+  for (( i = $1 + 1 ; i <= end_pos - start_pos ; i += 1 )) ; do
     (( j = i + start_pos - 1 ))
     (( k = j + 1 ))
     case "$arg[$i]" in
+      '"') break;;
+      '`') saved_reply=($reply)
+           _zsh_highlight_main_highlighter_highlight_backtick $i
+           (( i = REPLY ))
+           reply=($saved_reply $reply)
+           continue
+           ;;
       '$' ) style=dollar-double-quoted-argument
             # Look for an alphanumeric parameter name.
             if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
@@ -831,7 +1169,23 @@ _zsh_highlight_main_highlighter_highlight_string()
               (( k += 1 )) # highlight both dollar signs
               (( i += 1 )) # don't consider the second one as introducing another parameter expansion
             elif [[ $arg[i+1] == $'\x28' ]]; then
-              # Highlight just the '$'.
+              breaks+=( $last_break $(( start_pos + i - 1 )) )
+              (( i += 2 ))
+              saved_reply=($reply)
+              _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos]
+              ret=$?
+              (( i += REPLY ))
+              last_break=$(( start_pos + i ))
+              reply=(
+                $saved_reply
+                $j $(( start_pos + i )) command-substitution-quoted
+                $j $(( j + 2 )) command-substitution-delimiter-quoted
+                $reply
+              )
+              if (( ret == 0 )); then
+                reply+=($(( start_pos + i - 1 )) $(( start_pos + i )) command-substitution-delimiter-quoted)
+              fi
+              continue
             else
               continue
             fi
@@ -854,24 +1208,41 @@ _zsh_highlight_main_highlighter_highlight_string()
       *) continue ;;
 
     esac
-    _zsh_highlight_main_add_region_highlight $j $k $style
+    reply+=($j $k $style)
+  done
+
+  if [[ $arg[i] == '"' ]]; then
+    style=double-quoted-argument
+  else
+    # If unclosed, i points past the end
+    (( i-- ))
+    style=double-quoted-argument-unclosed
+  fi
+  (( last_break != start_pos + i )) && breaks+=( $last_break $(( start_pos + i )) )
+  saved_reply=($reply)
+  reply=()
+  for 1 2 in $breaks; do
+    reply+=($1 $2 $style)
   done
+  reply+=($saved_reply)
+  REPLY=$i
 }
 
 # Highlight special chars inside dollar-quoted strings
-_zsh_highlight_main_highlighter_highlight_dollar_string()
+_zsh_highlight_main_highlighter_highlight_dollar_quote()
 {
-  setopt localoptions noksharrays
   local -a match mbegin mend
   local MATCH; integer MBEGIN MEND
   local i j k style
   local AA
   integer c
-  # Starting dollar-quote is at 1:2, so start parsing at offset 3 in the string.
-  for (( i = 3 ; i < end_pos - start_pos ; i += 1 )) ; do
+  reply=()
+
+  for (( i = $1 + 2 ; i <= end_pos - start_pos ; i += 1 )) ; do
     (( j = i + start_pos - 1 ))
     (( k = j + 1 ))
     case "$arg[$i]" in
+      "'") break;;
       "\\") style=back-dollar-quoted-argument
             for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do
               [[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break
@@ -897,8 +1268,88 @@ _zsh_highlight_main_highlighter_highlight_dollar_string()
       *) continue ;;
 
     esac
-    _zsh_highlight_main_add_region_highlight $j $k $style
+    reply+=($j $k $style)
+  done
+
+  if [[ $arg[i] == "'" ]]; then
+    style=dollar-quoted-argument
+  else
+    # If unclosed, i points past the end
+    (( i-- ))
+    style=dollar-quoted-argument-unclosed
+  fi
+  reply=($(( start_pos + $1 - 1 )) $(( start_pos + i )) $style $reply)
+  REPLY=$i
+}
+
+# Highlight backtick substitutions
+_zsh_highlight_main_highlighter_highlight_backtick()
+{
+  # buf is the contents of the backticks with a layer of backslashes removed.
+  # last is the index of arg for the start of the string to be copied into buf.
+  #     It is either one past the beginning backtick or one past the last backslash.
+  # offset is a count of consumed \ (the delta between buf and arg).
+  # offsets is an array indexed by buf offset of when the delta between buf and arg changes.
+  #     It is sparse, so search backwards to the last value
+  local buf highlight style=back-quoted-argument-unclosed style_end
+  local -i arg1=$1 end_ i=$1 last offset=0 start subshell_has_end=0
+  local -a highlight_zone highlights offsets
+  reply=()
+
+  last=$(( arg1 + 1 ))
+  # Remove one layer of backslashes and find the end
+  while i=$arg[(ib:i+1:)[\\\\\`]]; do # find the next \ or `
+    if (( i > end_pos - start_pos )); then
+      buf=$buf$arg[last,i]
+      offsets[i-arg1-offset]='' # So we never index past the end
+      (( i-- ))
+      subshell_has_end=$(( has_end && (start_pos + i == len) ))
+      break
+    fi
+
+    if [[ $arg[i] == '\' ]]; then
+      (( i++ ))
+      # POSIX XCU 2.6.3
+      if [[ $arg[i] == ('$'|'`'|'\') ]]; then
+        buf=$buf$arg[last,i-2]
+        (( offset++ ))
+        # offsets is relative to buf, so adjust by -arg1
+        offsets[i-arg1-offset]=$offset
+      else
+        buf=$buf$arg[last,i-1]
+      fi
+    else # it's an unquoted ` and this is the end
+      style=back-quoted-argument
+      style_end=back-quoted-argument-delimiter
+      buf=$buf$arg[last,i-1]
+      offsets[i-arg1-offset]='' # So we never index past the end
+      break
+    fi
+    last=$i
   done
+
+  _zsh_highlight_main_highlighter_highlight_list 0 '' $subshell_has_end $buf
+
+  # Munge the reply to account for removed backslashes
+  for start end_ highlight in $reply; do
+    start=$(( start_pos + arg1 + start + offsets[(Rb:start:)?*] ))
+    end_=$(( start_pos + arg1 + end_ + offsets[(Rb:end_:)?*] ))
+    highlights+=($start $end_ $highlight)
+    if [[ $highlight == back-quoted-argument-unclosed && $style == back-quoted-argument ]]; then
+      # An inner backtick command substitution is unclosed, but this level is closed
+      style_end=unknown-token
+    fi
+  done
+
+  reply=(
+    $(( start_pos + arg1 - 1 )) $(( start_pos + i )) $style
+    $(( start_pos + arg1 - 1 )) $(( start_pos + arg1 )) back-quoted-argument-delimiter
+    $highlights
+  )
+  if (( $#style_end )); then
+    reply+=($(( start_pos + i - 1)) $(( start_pos + i )) $style_end)
+  fi
+  REPLY=$i
 }
 
 # Called with a single positional argument.
@@ -912,7 +1363,7 @@ _zsh_highlight_main_highlighter_expand_path()
   # The $~1 syntax normally performs filename generation, but not when it's on the right-hand side of ${x:=y}.
   setopt localoptions nonomatch
   unset REPLY
-  : ${REPLY:=${(Q)~1}}
+  : ${REPLY:=${(Q)${~1}}}
 }
 
 # -------------------------------------------------------------------------------------------------
@@ -923,7 +1374,7 @@ _zsh_highlight_main__precmd_hook() {
   _zsh_highlight_main__command_type_cache=()
 }
 
-autoload -U add-zsh-hook
+autoload -Uz add-zsh-hook
 if add-zsh-hook precmd _zsh_highlight_main__precmd_hook 2>/dev/null; then
   # Initialize command type cache
   typeset -gA _zsh_highlight_main__command_type_cache
@@ -932,3 +1383,4 @@ else
   # Make sure the cache is unset
   unset _zsh_highlight_main__command_type_cache
 fi
+typeset -ga X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-comment1.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-comment1.zsh
new file mode 100644 (file)
index 0000000..0c449e1
--- /dev/null
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+# see alias-comment2.zsh
+setopt interactivecomments
+alias x=$'# foo\npwd'
+BUFFER='x'
+
+expected_region_highlight=(
+  '1 1 alias' # x
+  '1 1 comment' # x (#)
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-comment2.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-comment2.zsh
new file mode 100644 (file)
index 0000000..8bdc5a8
--- /dev/null
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+# see alias-comment1.zsh
+setopt NO_interactivecomments
+alias x=$'# foo\npwd'
+BUFFER='x'
+
+expected_region_highlight=(
+  '1 1 alias' # x
+  '1 1 unknown-token' # x (#)
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-complex.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-complex.zsh
new file mode 100644 (file)
index 0000000..7a9626e
--- /dev/null
@@ -0,0 +1,39 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias x='echo && ls; >'
+
+BUFFER='x file echo'
+
+expected_region_highlight=(
+  '1 1 alias' # x
+  '1 1 builtin' # x (echo)
+  '3 6 default' # file
+  '8 11 builtin' # echo
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-empty.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-empty.zsh
new file mode 100644 (file)
index 0000000..535fccc
--- /dev/null
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias x=''
+
+BUFFER='x echo foo'
+
+expected_region_highlight=(
+  '1 1 alias' # x
+  '3 6 builtin' # echo
+  '8 10 default' # foo
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-loop.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-loop.zsh
new file mode 100644 (file)
index 0000000..b36d1c9
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias a=b b=c c=b
+
+BUFFER='a foo; :'
+
+expected_region_highlight=(
+  '1 1 alias' # a
+  '1 1 unknown-token' # a (invalid alias loop)
+  '3 5 default' # foo
+  '6 6 commandseparator' # ;
+  '8 8 builtin' # :
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-nested-precommand.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-nested-precommand.zsh
new file mode 100644 (file)
index 0000000..7c2eeeb
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias a=b b=sudo
+sudo(){}
+
+BUFFER='a -u phy1729 echo; :'
+
+expected_region_highlight=(
+  '1 1 alias' # a
+  '1 1 precommand' # a (sudo)
+  '3 4 single-hyphen-option' # -u
+  '6 12 default' # phy1729
+  '14 17 builtin' # echo
+  '18 18 commandseparator' # ;
+  '20 20 builtin' # :
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-nested.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-nested.zsh
new file mode 100644 (file)
index 0000000..44ab22b
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias a=b b=:
+
+BUFFER='a foo; :'
+
+expected_region_highlight=(
+  '1 1 alias' # a
+  '1 1 builtin' # a (:)
+  '3 5 default' # foo
+  '6 6 commandseparator' # ;
+  '8 8 builtin' # :
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument1.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument1.zsh
new file mode 100644 (file)
index 0000000..ad16962
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias sdu='sudo -u'
+sudo(){}
+
+BUFFER='sdu phy1729 echo foo'
+
+expected_region_highlight=(
+  '1 3 alias' # sdu
+  '1 3 precommand' # sdu (sudo)
+  '5 11 default' # phy1729
+  '13 16 commmand "issue #540"' # echo (not builtin)
+  '18 20 default' # foo
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument2.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-precommand-option-argument2.zsh
new file mode 100644 (file)
index 0000000..2fceff8
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias sde='sudo -e'
+alias seu='sde -u'
+sudo(){}
+
+BUFFER='seu phy1729 echo foo'
+
+expected_region_highlight=(
+  '1 3 alias' # seu
+  '1 3 precommand' # seu (sudo)
+  '5 11 default' # phy1729
+  '13 16 commmand "issue #540"' # echo (not builtin)
+  '18 20 default' # foo
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-quoted.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-quoted.zsh
new file mode 100644 (file)
index 0000000..e42e2f0
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) YYYY zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias a=: ls='ls -l'
+BUFFER='"a" foo; \ls'
+
+expected_region_highlight=(
+  '1 3 unknown-token' # "a"
+  '5 7 default' # foo
+  '8 8 commandseparator' # ;
+  '10 12 command' # \ls
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-redirect.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-redirect.zsh
new file mode 100644 (file)
index 0000000..a6a0aab
--- /dev/null
@@ -0,0 +1,39 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias x=\>
+BUFFER='x foo echo bar'
+
+expected_region_highlight=(
+  '1 1 alias' # x
+  '1 1 redirection' # x (>)
+  '3 5 default' # foo
+  '7 10 builtin' # echo
+  '12 14 default' # bar
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-self.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-self.zsh
new file mode 100644 (file)
index 0000000..88ed3c8
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias echo='echo foo'
+
+BUFFER='echo bar'
+
+expected_region_highlight=(
+  '1 4 alias' # echo
+  '1 4 builtin' # echo
+  '6 8 default' # bar
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-to-dir.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/alias-to-dir.zsh
new file mode 100644 (file)
index 0000000..93aaa62
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+alias x=/
+BUFFER=$'x'
+
+expected_region_highlight=(
+  '1 1 alias' # x
+  '1 1 unknown-token "issue #202"' # x (/)
+)
index 2977343..03ca0be 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-alias alias1="unused expansion"
+alias alias1="ls"
 alias -s alias2="echo"
-if set -o | grep -q aliasfuncdef; then
-  setopt alias_func_def # 5.4+
-fi
-alias1() {} # to check that it's highlighted as an alias, not as a function
+function alias1() {} # to check that it's highlighted as an alias, not as a function
 
-BUFFER='x.alias2; alias1'
+BUFFER='x.alias2; alias1; alias2'
 
 # Set expected_region_highlight as a function of zsh version.
 #
@@ -43,11 +40,15 @@ BUFFER='x.alias2; alias1'
 # functionality is present, and skip verifying suffix-alias highlighting
 # if it isn't.
 expected_region_highlight=()
-if [[ "$(type -w x.alias2)" == *suffix* ]]; then
+if zmodload -e zsh/parameter || [[ "$(type -w x.alias2)" == *suffix* ]]; then
   expected_region_highlight+=(
     "1 8 suffix-alias" # x.alias2
   )
 fi
 expected_region_highlight+=(
+  "9 9 commandseparator" # ;
   "11 16 alias" # alias1
+  "11 16 command" # alias1 (ls)
+  "17 17 commandseparator" # ;
+  "19 24 unknown-token" # alias2
 )
index 5b8e0b6..9d67fb1 100644 (file)
@@ -37,5 +37,8 @@ expected_region_highlight=(
   "16 17 reserved-word" # ()
   "19 19 reserved-word" # {
   "21 24 builtin" # echo
+  "26 30 default" # world
+  "32 32 reserved-word" # }
+  "34 43 default" # "argument"
   "34 43 double-quoted-argument" # "argument"
 )
index 6485f0e..eb9fbbd 100644 (file)
@@ -31,4 +31,7 @@ BUFFER='a+=(lorem ipsum)'
 
 expected_region_highlight=(
   "1 4 assign" # a+=(
+  "5 9 default" # lorem
+  "11 15 default" # ipsum
+  "16 16 assign" # )
 )
index fdf30aa..ec5acc2 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+touch foo
 BUFFER='42=foo 43+=bar'
 
 expected_region_highlight=(
   "1 6 assign" # 42=foo
+  "4 6 path" # foo
   "8 14 assign" # 43+=bar
+  "12 14 default" # bar
 )
index 8995162..0624f9b 100644 (file)
@@ -32,6 +32,8 @@ BUFFER='(A=(hello world))'
 expected_region_highlight=(
   "1 1 reserved-word" # (
   "2 4 assign" # A=(
+  "5 9 default" # hello
+  "11 15 default" # world
   "16 16 assign" # )
   "17 17 reserved-word" # )
 )
index 37ba372..cdc9e63 100644 (file)
@@ -31,6 +31,8 @@ BUFFER='A=(hello world) ls'
 
 expected_region_highlight=(
   "1 3 assign" # A=(
+  "4 8 default" # hello
+  "10 14 default" # world
   "15 15 assign" # )
   "17 18 command" # ls
 )
index 26c42e9..986d71f 100644 (file)
@@ -31,6 +31,9 @@ BUFFER='A=(hello world) b=42'
 
 expected_region_highlight=(
   "1 3 assign" # A=(
+  "4 8 default" # hello
+  "10 14 default" # world
   "15 15 assign" # )
   "17 20 assign" # b=42
+  "19 20 default" # 42
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-not-array.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-not-array.zsh
new file mode 100644 (file)
index 0000000..651ab80
--- /dev/null
@@ -0,0 +1,36 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='a=foo( bar ) :'
+
+expected_region_highlight=(
+  '1 12 assign' # a=foo( bar )
+  '3 12 default' # foo( bar )
+  '14 14 builtin' # :
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-not-array2.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/assign-not-array2.zsh
new file mode 100644 (file)
index 0000000..dfda106
--- /dev/null
@@ -0,0 +1,36 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='a=foo\( :'
+
+expected_region_highlight=(
+  '1 7 assign' # a=foo\(
+  '3 7 default' # foo\(
+  '9 9 builtin' # :
+)
index c2618b0..f748c94 100644 (file)
 BUFFER='A=1; echo hello world'
 
 expected_region_highlight=(
+  "1 3 assign" # A=1
+  "3 3 default" # 1
   "4 4 commandseparator" # ;
   "6 9 builtin" # echo
+  "11 15 default" # hello
+  "17 21 default" # world
 )
index fc04f6b..2022889 100644 (file)
@@ -32,5 +32,6 @@ BUFFER='(A=1)'
 expected_region_highlight=(
   "1 1 reserved-word" # (
   "2 4 assign" # A=1
+  "4 4 default" # 1
   "5 5 reserved-word" # )
 )
index 713a5f2..6e797ac 100644 (file)
@@ -31,7 +31,9 @@ BUFFER='A=1 b=("foo" bar)'
 
 expected_region_highlight=(
   "1 3 assign" # A=1
+  "3 3 default" # 1
   "5 7 assign" # b=(
+  "8 12 default" # "foo"
   "8 12 double-quoted-argument" # "foo"
   "14 16 default" # bar
   "17 17 assign" # )
index f8329ea..d504a2c 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-BUFFER='echo `echo 42`'
+BUFFER='echo `echo \`42\`` "is `echo equal` to" `echo 6 times 9'
 
 expected_region_highlight=(
-  "6 14 back-quoted-argument"
+  "1 4 builtin" # echo
+  "6 18 default" # `echo \`42\``
+  "6 18 back-quoted-argument" # `echo \`42\``
+  "6 6 back-quoted-argument-delimiter" # `
+  "7 10 builtin" # echo
+  "12 17 default" # \`42\`
+  "12 17 back-quoted-argument" # \`42\`
+  "12 13 back-quoted-argument-delimiter" # \`
+  "14 15 unknown-token" # 42
+  "16 17 back-quoted-argument-delimiter" # \`
+  "18 18 back-quoted-argument-delimiter" # `
+  "20 39 default" # "is `echo equal` to"
+  "20 39 double-quoted-argument" # "is `echo equal` to"
+  "24 35 back-quoted-argument" # `echo equal`
+  "24 24 back-quoted-argument-delimiter" # `
+  "25 28 builtin" # echo
+  "30 34 default" # equal
+  "35 35 back-quoted-argument-delimiter" # `
+  "41 55 default" # `echo 6 times 9
+  "41 55 back-quoted-argument-unclosed" # `echo 6 times 9
+  "41 41 back-quoted-argument-delimiter" # `
+  "42 45 builtin" # echo
+  "47 47 default" # 6
+  "49 53 default" # times
+  "55 55 default" # 9
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/back-quoted-open.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/back-quoted-open.zsh
new file mode 100644 (file)
index 0000000..f188d81
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+touch foo
+BUFFER=$': `ls fo'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 8 default' # `ls fo
+  '3 8 back-quoted-argument-unclosed' # `ls fo
+  '3 3 back-quoted-argument-delimiter' # `
+  '4 5 command' # ls
+  '7 8 path_prefix' # fo
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/backslash-space.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/backslash-space.zsh
new file mode 100644 (file)
index 0000000..0d8a63c
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'echo \\ \'foo\' ; ls'
+
+expected_region_highlight=(
+  '1 4 builtin' # echo
+  '6 12 default' # \ \'foo\'
+  '8 12 single-quoted-argument' # 'foo'
+  '14 14 commandseparator' # ;
+  '16 17 command' # ls
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-assign-array.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-assign-array.zsh
new file mode 100644 (file)
index 0000000..77b57e6
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'foo=(bar abaz) \! ls'
+
+expected_region_highlight=(
+  '1 5 assign' # foo=(
+  '6 8 default' # bar
+  '10 13 default' # abaz
+  '14 14 assign' # )
+  '16 16 unknown-token' # \!
+  '18 19 command' # ls
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-assign-scalar.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-assign-scalar.zsh
new file mode 100644 (file)
index 0000000..e919050
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'foo=bar \! ls'
+
+expected_region_highlight=(
+  '1 7 assign' # foo=bar
+  '5 7 default' # bar
+  '9 9 unknown-token' # \!
+  '11 12 command' # ls
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-pipeline.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/bang-pipeline.zsh
new file mode 100644 (file)
index 0000000..fef25f1
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'\! ls | \! ls'
+
+expected_region_highlight=(
+  '1 1 reserved-word' # \!
+  '3 4 command' # ls
+  '6 6 commandseparator' # |
+  '8 8 unknown-token' # \!
+  '10 11 command' # ls
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-matching1.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-matching1.zsh
new file mode 100644 (file)
index 0000000..7cc6de5
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='[[ -n foo ]]'
+
+expected_region_highlight=(
+  '1 2 reserved-word' # [[
+  '4 5 single-hyphen-option' # -n
+  '7 9 default' # foo
+  '11 12 reserved-word' # ]]
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-matching2.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-matching2.zsh
new file mode 100644 (file)
index 0000000..19c7f0d
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='[ -n foo ]'
+
+expected_region_highlight=(
+  '1 1 builtin' # [
+  '3 4 single-hyphen-option' # -n
+  '6 8 default' # foo
+  '10 10 builtin' # ]
+)
index 27d5920..1caa936 100644 (file)
@@ -34,6 +34,7 @@ expected_region_highlight=(
   '1 3 reserved-word' # for
   '5 5 default' # n
   '7 8 default' # in
+  '10 10 default' # *
   '10 10 globbing' # *
   '11 11 commandseparator' # ;
   '13 14 reserved-word' # do
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-premature-termination.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/brackets-premature-termination.zsh
new file mode 100644 (file)
index 0000000..fa813da
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='[[ -n foo; echo ]]'
+
+expected_region_highlight=(
+  '1 2 reserved-word' # [[
+  '4 5 single-hyphen-option' # -n
+  '7 9 default' # foo
+  '10 10 unknown-token' # ;
+  '12 15 builtin' # echo
+  '17 18 default' # ]]
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-in-assignment.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-in-assignment.zsh
new file mode 100644 (file)
index 0000000..fafda49
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'foo=$(echo bar) :'
+
+expected_region_highlight=(
+  '1 15 assign' # foo=$(echo bar)
+  '5 15 default' # $(echo bar)
+  '5 15 command-substitution-unquoted' # $(echo bar)
+  '5 6 command-substitution-delimiter-unquoted' # $(
+  '7 10 builtin' # echo
+  '12 14 default' # bar
+  '15 15 command-substitution-delimiter-unquoted' # )
+  '17 17 builtin' # :
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-unclosed.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/command-substitution-unclosed.zsh
new file mode 100644 (file)
index 0000000..3229dfc
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': foo$(echo bar'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 15 default' # foo$(echo bar
+  '6 15 command-substitution-unquoted' # $(echo bar
+  '6 7 command-substitution-delimiter-unquoted' # $(
+  '8 11 builtin' # echo
+  '13 15 default' # bar
+)
+
+if [[ ${(z):-'$('} == '$( ' ]]; then # ignore zsh 5.0.8 bug
+  expected_region_highlight[2]='3 16 default' # foo$(echo bar
+  expected_region_highlight[3]='6 16 command-substitution-unquoted' # $(echo bar
+fi
index e8d93a6..f504847 100644 (file)
@@ -30,6 +30,7 @@
 BUFFER=':; pwd &! ls'
 
 expected_region_highlight=(
+  "1 1 builtin" # :
   "2 2 commandseparator" # ;
   "4 6 builtin" # pwd
   "8 9 commandseparator" # &!
index af4e9b5..8c7e42c 100644 (file)
@@ -32,8 +32,7 @@ setopt interactivecomments
 BUFFER=$'# foo\ntrue'
 
 expected_region_highlight=(
-  '1 5 comment' # #
-  #'6 6 '"' # \n
-
+  '1 5 comment' # # foo
+  '6 6 commandseparator "issue #501"' # \n
   '7 10 builtin' # true
 )
index f750cc4..b4c9910 100644 (file)
@@ -32,6 +32,5 @@ setopt interactive_comments
 BUFFER='# echo foo'
 
 expected_region_highlight=(
-  "1 1 comment" # #
-  "2 10 comment" # " echo foo"
+  "1 10 comment" # # echo foo
 )
index 3bb008e..f3cc57e 100644 (file)
@@ -33,6 +33,7 @@ BUFFER='echo "foo #bar" #baz # quux'
 
 expected_region_highlight=(
   "1 4 builtin" # echo
+  "6 15 default" # "foo #bar"
   "6 15 double-quoted-argument" # "foo #bar"
   "17 27 comment" # #baz # quux
 )
index 355f890..48d20ba 100644 (file)
 # -------------------------------------------------------------------------------------------------
 
 local x=/usr/bin/env
-BUFFER='$x "argument"'
+local y=sudo
+local -a z; z=(zsh -f)
+sudo(){}
+
+BUFFER='$x "argument"; $y; $z'
 
 expected_region_highlight=(
   "1 2 command" # $x
+  "4 13 default" # "argument"
   "4 13 double-quoted-argument" # "argument"
+  "14 14 commandseparator" # ;
+  "16 17 precommand" # $y (sudo)
+  "18 18 unknown-token" # ;
+  "20 21 command" # $z - 'zsh' being the command
 )
index 2f6a160..a610bdc 100644 (file)
@@ -34,17 +34,24 @@ expected_region_highlight+=(
   "7 8 reserved-word" # if
   "10 13 builtin" # echo
   "15 19 default" # Hello
+  "20 20 commandseparator" # ;
   "22 25 reserved-word" # then
   "27 28 command" # ls
   "30 30 path" # /
   "31 31 commandseparator" # ;
   "33 36 reserved-word" # else
   "38 39 command" # ls
+  "40 40 commandseparator" # ;
   "42 43 reserved-word" # fi
+  "44 44 commandseparator" # ;
   "46 47 reserved-word" # do
   "49 52 command" # stat
+  "54 56 default" # "x"
   "54 56 double-quoted-argument" # "x"
+  "57 57 commandseparator" # ;
   "59 62 reserved-word" # done
+  "63 63 commandseparator" # ;
   "65 70 reserved-word" # repeat
+  "72 73 default" # 10
   "75 76 command" # ls
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/cthulhu.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/cthulhu.zsh
new file mode 100644 (file)
index 0000000..c8119a8
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+#        0000000 0 01111111111222222 222233333 3 333344 4 4 444444555555555 5 6 6666 6 6 6667777777777888 8 8 88888999 9 9999 9 9 00 00 0000001111
+#        1234567 8 90123456789012345 678901234 5 678901 2 3 456789012345678 9 0 1234 5 6 7890123456789012 3 4 56789012 3 4567 8 9 01 23 4567890123
+BUFFER=$'echo Ph\\\'ng`echo lui "mg"\\`echo lw\\\'nafh \\\\\\`echo Cthu"lhu\\\\\\` R\\\\\'ly$(echo eh wag\\\\\\`echo h\\\'nag\\\\\\`\'l\' fht)agn`'
+
+expected_region_highlight=(
+  '1 4 builtin' # echo
+  '6 113 default' # Ph\'ng`echo lui "mg"\`echo lw\'nafh \\\`echo Cthu"lhu\\\` R\\'ly$(echo eh wag\\\`echo h\'nag\\\`'l' fht)agn`
+  '12 113 back-quoted-argument' # `echo lui "mg"\`echo lw\'nafh \\\`echo Cthu"lhu\\\` R\\'ly$(echo eh wag\\\`echo h\'nag\\\`'l' fht)agn`
+  '12 12 back-quoted-argument-delimiter' # `
+  '13 16 builtin' # echo
+  '18 20 default' # lui
+  '22 112 default' # "mg"\`echo lw\'nafh \\\`echo Cthu"lhu\\\` R\\'ly$(echo eh wag\\\`echo h\'nag\\\`'l' fht)agn
+  '22 25 double-quoted-argument' # "mg"
+  '26 112 back-quoted-argument-unclosed' # \`echo lw\'nafh \\\`echo Cthu"lhu\\\` R\\'ly$(echo eh wag\\\`echo h\'nag\\\`'l' fht)agn
+  '26 27 back-quoted-argument-delimiter' # \`
+  '28 31 builtin' # echo
+  '33 40 default' # lw\'nafh
+  '42 62 default' # \\\`echo Cthu"lhu\\\`
+  '42 62 back-quoted-argument' # \\\`echo Cthu"lhu\\\`
+  '42 45 back-quoted-argument-delimiter' # \\\`
+  '46 49 builtin' # echo
+  '51 58 default' # Cthu"lhu
+  '55 58 double-quoted-argument-unclosed' # "lhu
+  '59 62 back-quoted-argument-delimiter' # \\\`
+  '64 112 default' # R\\'ly$(echo eh wag\\\`echo h\'nag\\\`'l' fht)agn
+  '70 109 command-substitution-unquoted' # $(echo eh wag\\\`echo h\'nag\\\`'l' fht)
+  '70 71 command-substitution-delimiter-unquoted' # $(
+  '72 75 builtin' # echo
+  '77 78 default' # eh
+  '80 104 default' # wag\\\`echo h\'nag\\\`'l'
+  '83 101 back-quoted-argument' # \\\`echo h\'nag\\\`
+  '83 86 back-quoted-argument-delimiter' # \\\`
+  '87 90 builtin' # echo
+  '92 97 default' # h\'nag
+  '98 101 back-quoted-argument-delimiter' # \\\`
+  '102 104 single-quoted-argument' # 'l'
+  '106 108 default' # fht
+  '109 109 command-substitution-delimiter-unquoted' # )
+  '113 113 unknown-token' # `
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dirs_blacklist.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/dirs_blacklist.zsh
new file mode 100644 (file)
index 0000000..8cf04be
--- /dev/null
@@ -0,0 +1,40 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+mkdir foo
+touch foo/bar
+BUFFER=": foo/bar $PWD/foo foo/b"
+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo $PWD/bar)
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 9 default' # foo/bar
+  "11 $(( 14 + $#PWD )) default" # $PWD/foo
+  "$(( 16 + $#PWD )) $(( 20 + $#PWD )) default" # foo/b
+)
index 79d7f7d..e3f387c 100644 (file)
@@ -32,8 +32,8 @@ BUFFER=': "$$ $$foo"'
 
 expected_region_highlight=(
   '1 1 builtin' # :
-  '3 3 double-quoted-argument' # "
+  '3 12 default' # "$$ $$foo"
+  '3 12 double-quoted-argument' # "$$ $$foo"
   '4 5 dollar-double-quoted-argument' # $$
   '7 8 dollar-double-quoted-argument' # $$
-  '9 12 double-quoted-argument' # foo"
 )
index e900b02..9bb11bd 100644 (file)
@@ -32,15 +32,11 @@ BUFFER=': "$- $# $* $@ $?"'
 
 expected_region_highlight=(
   '1 1 builtin' # :
-  '3 3 double-quoted-argument' # "
+  '3 18 default' # "$- $# $* $@ $?"
+  '3 18 double-quoted-argument' # "$- $# $* $@ $?"
   '4 5 dollar-double-quoted-argument' # $-
-  '6 6 double-quoted-argument' # <space>
   '7 8 dollar-double-quoted-argument' # $#
-  '9 9 double-quoted-argument' # <space>
   '10 11 dollar-double-quoted-argument' # $*
-  '12 12 double-quoted-argument' # <space>
   '13 14 dollar-double-quoted-argument' # $@
-  '15 15 double-quoted-argument' # <space>
   '16 17 dollar-double-quoted-argument' # $?
-  '18 18 double-quoted-argument' # "
 )
index 354daa0..2bbcef1 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-BUFFER=': "$(:)"'
+BUFFER=': "$(:)" "foo$(:)bar'
 
 expected_region_highlight=(
   '1 1 builtin' # :
-  '3 3 double-quoted-argument' # "
-  '4 4 dollar-double-quoted-argument' # $
-  '5 8 double-quoted-argument' # (:)"
+  '3 8 default' # "$(:)"
+  '3 3 double-quoted-argument' # "$(:)"
+  '8 8 double-quoted-argument' # "$(:)"
+  '4 7 command-substitution-quoted' # $(:)
+  '4 5 command-substitution-delimiter-quoted' # $(
+  '6 6 builtin' # :
+  '7 7 command-substitution-delimiter-quoted' # )
+  '10 20 default' # "foo$(:)bar
+  '10 13 double-quoted-argument-unclosed' # "foo
+  '18 20 double-quoted-argument-unclosed' # bar
+  '14 17 command-substitution-quoted' # $(:)
+  '14 15 command-substitution-delimiter-quoted' # $(
+  '16 16 builtin' # :
+  '17 17 command-substitution-delimiter-quoted' # )
 )
index 8c4c16f..081a365 100644 (file)
@@ -30,6 +30,9 @@
 BUFFER=": \$'*' 'foo'"
 
 expected_region_highlight=(
+  "1 1 builtin" # :
+  "3 6 default" # $'*'
   "3 6 dollar-quoted-argument" # $'*' - not a glob
+  "8 12 default" # 'foo'
   "8 12 single-quoted-argument" # 'foo'
 )
index a69373f..ed7428b 100644 (file)
 BUFFER=": \$'foo\xbar\udeadbeef\uzzzz'"
 
 expected_region_highlight=(
-  "3 7 dollar-quoted-argument" # $'foo
+  "1 1 builtin" # :
+  "3 29 default" # $'foo\xbar\udeadbeef\uzzzz'
+  "3 29 dollar-quoted-argument" # $'foo\xbar\udeadbeef\uzzzz'
   "8 11 back-dollar-quoted-argument" # \xba
-  "12 12 dollar-quoted-argument" # r
   "13 18 back-dollar-quoted-argument" # \dead
-  "19 22 dollar-quoted-argument" # beef
   "23 24 unknown-token" # \u
-  "25 29 dollar-quoted-argument" # zzzz'
 )
index 320cd94..365f351 100644 (file)
@@ -32,6 +32,8 @@
 BUFFER=": \$'\xa1"
 
 expected_region_highlight=(
-  "3 4 dollar-quoted-argument" # $'
+  "1 1 builtin" # :
+  "3 8 default" # $'\xa1
+  "3 8 dollar-quoted-argument-unclosed" # $'\xa1
   "5 8 back-dollar-quoted-argument" # \xa1
 )
index 7e379f8..0a4336c 100644 (file)
@@ -31,15 +31,12 @@ BUFFER=': "foo$bar:\`:\":\$:'
 BUFFER+=\\\\:\"
 
 expected_region_highlight=(
-  "3 6 double-quoted-argument" # "foo
+  "1 1 builtin" # :
+  "3 24 default" # "foo$bar:\`:\":\$:\\:"
+  "3 24 double-quoted-argument" # "foo$bar:\`:\":\$:\\:"
   "7 10 dollar-double-quoted-argument" # $bar
-  "11 11 double-quoted-argument" # :
   "12 13 back-double-quoted-argument" # \`
-  "14 14 double-quoted-argument" # :
   "15 16 back-double-quoted-argument" # \$
-  "17 17 double-quoted-argument" # :
   "18 19 back-double-quoted-argument" # \"
-  "20 20 double-quoted-argument" # :
   "21 22 back-double-quoted-argument" # \\
-  "23 24 double-quoted-argument" # :"
 )
index 1538423..c400e54 100644 (file)
@@ -32,6 +32,8 @@
 BUFFER=': "foo$bar'
 
 expected_region_highlight=(
-  "3 6 double-quoted-argument" # "foo
+  "1 1 builtin" # :
+  "3 10 default" # "foo$bar
+  "3 10 double-quoted-argument-unclosed" # "foo$bar
   "7 10 dollar-double-quoted-argument" # $bar
 )
index 39514e0..86e3ced 100644 (file)
@@ -31,9 +31,12 @@ BUFFER=': "$" "$42foo"'
 BUFFER+=\ \"\\\'\\x\"
 
 expected_region_highlight=(
+  "1 1 builtin" # :
+  "3 5 default" # "$"
   "3 5 double-quoted-argument" # "$"
-  "7 7 double-quoted-argument" # "
+  "7 14 default" # "$42foo"
+  "7 14 double-quoted-argument" # "$42foo"
   "8 10 dollar-double-quoted-argument" # $42
-  "11 14 double-quoted-argument" # foo"
+  "16 21 default" # "\'\x"
   "16 21 double-quoted-argument" # "\'\x" - \' and \x are not escape sequences
 )
index 51bb25e..c59d5d8 100644 (file)
@@ -30,7 +30,8 @@
 BUFFER=': "${foo}bar"'
 
 expected_region_highlight=(
-  "3 3 double-quoted-argument" # "
+  "1 1 builtin" # :
+  "3 13 default" # "${foo}bar"
+  "3 13 double-quoted-argument" # "${foo}bar"
   "4 9 dollar-double-quoted-argument" # ${foo}
-  "10 13 double-quoted-argument" # bar"
 )
index 6e68184..5831464 100644 (file)
@@ -30,6 +30,7 @@
 BUFFER='echo; ;'
 
 expected_region_highlight=(
+  "1 4 builtin" # echo
   "5 5 commandseparator" # ;
   "7 7 unknown-token" # ;
 )
index 698b3a7..dcb4e6f 100644 (file)
@@ -33,6 +33,7 @@ touch ';'
 BUFFER='echo; ;'
 
 expected_region_highlight=(
+  "1 4 builtin" # echo
   "5 5 commandseparator" # ;
   "7 7 unknown-token" # ;
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/empty-line.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/empty-line.zsh
new file mode 100644 (file)
index 0000000..a4d6685
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'\\\n; ls'
+
+expected_region_highlight=(
+  '3 3 unknown-token' # ;
+  '5 6 command' # ls
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/escaped-single-quote.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/escaped-single-quote.zsh
new file mode 100644 (file)
index 0000000..4b2fe4b
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': \'foo\'\\\'\'bar\'' # <<<: 'foo'\''bar'>>>
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 14 default' # 'foo'\''bar'
+  '3 7 single-quoted-argument' # 'foo'
+  '10 14 single-quoted-argument' # 'bar'
+)
index caec2f1..78a0c62 100644 (file)
@@ -31,8 +31,8 @@ BUFFER='exec {foo}>&/tmp ls'
 
 expected_region_highlight=(
   "1 4 precommand" # exec
-  "6 10 redirection 'issue #238'" # {foo}
+  "6 10 named-fd" # {foo}
   "11 12 redirection" # >&
   "13 16 path" # /tmp
-  "18 19 command 'issue #238'" # ls
+  "18 19 command" # ls
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/function-altsyntax.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/function-altsyntax.zsh
new file mode 100644 (file)
index 0000000..0f9a833
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+# Define named and anonymous function using the alternative syntax
+BUFFER=$'function f { pwd }; function { pwd }'
+
+expected_region_highlight=(
+  '1 8 reserved-word' # function
+  '10 10 default' # f
+  '12 12 reserved-word "issue #237"' # {
+  '14 16 command "issue #237"' # pwd
+  '18 18 reserved-word "issue #237"' # }
+  '19 19 commandseparator' # ;
+  '21 28 reserved-word' # function
+  '30 30 reserved-word "issue #237"' # {
+  '32 34 command "issue #237"' # pwd
+  '36 36 reserved-word "issue #237"' # }
+)
index 426ee76..b1be853 100644 (file)
@@ -37,5 +37,6 @@ BUFFER='cd;ls'
 
 expected_region_highlight=(
   "1 2 function" # cd
+  "3 3 commandseparator" # ;
   "4 5 function" # ls
 )
index 2fd9c6f..2ff1022 100644 (file)
@@ -31,8 +31,11 @@ BUFFER=': foo* bar? *baz qux\?'
 
 expected_region_highlight=(
   "1 1 builtin" # :
-  "3 6 globbing" # foo*
-  "8 11 globbing" # bar?
-  "13 16 globbing" # *baz
+  "3 6 default" # foo*
+  "6 6 globbing" # *
+  "8 11 default" # bar?
+  "11 11 globbing" # ?
+  "13 16 default" # *baz
+  "13 13 globbing" # *
   "18 22 default" # qux\?
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/globs-with-quoting.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/globs-with-quoting.zsh
new file mode 100644 (file)
index 0000000..d7d74bc
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': "foo"*\'bar\'?"baz?"<17-29>"qu*ux"'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 34 default' # "foo"*'bar'?"baz?"<17-29>"qu*ux"
+  '3 7 double-quoted-argument' # "foo"
+  '8 8 globbing' # *
+  '9 13 single-quoted-argument' # 'bar'
+  '14 14 globbing' # ?
+  '15 20 double-quoted-argument' # "baz?"
+  '21 27 globbing' # <17-29>
+  '28 34 double-quoted-argument' # "qu*ux"
+)
index c447a78..7807cc0 100644 (file)
@@ -32,7 +32,7 @@ BUFFER='echo "Hello\!"'
 
 expected_region_highlight=(
   '1 4 builtin' # echo
-  '6 11 double-quoted-argument' # "Hello
+  '6 14 default' # "Hello\!"
+  '6 14 double-quoted-argument' # "Hello\!"
   '12 13 back-double-quoted-argument' # \!
-  '14 14 double-quoted-argument' # "Hello\!"
 )
index 7867e83..e082dbc 100644 (file)
@@ -32,5 +32,6 @@ BUFFER='echo "foo != bar !{baz}"'
 
 expected_region_highlight=(
   '1 4 builtin' # echo
+  '6 24 default' # "foo != bar !{baz}"
   '6 24 double-quoted-argument' # "foo != bar !{baz}" - no history expansions
 )
index c828b44..cfe6a11 100644 (file)
@@ -32,7 +32,7 @@ BUFFER='echo "Hello!"'
 
 expected_region_highlight=(
   '1 4 builtin' # echo
-  '6 11 double-quoted-argument' # "Hello
+  '6 13 default' # "Hello!"
+  '6 13 double-quoted-argument' # "Hello!"
   '12 12 history-expansion' # !
-  '13 13 double-quoted-argument' # "
 )
index 88c300e..e963c3b 100644 (file)
@@ -32,7 +32,7 @@ BUFFER='echo "foo !bar"'
 
 expected_region_highlight=(
   '1 4 builtin' # echo
-  '6 10 double-quoted-argument' # "foo 
+  '6 15 default' # "foo !bar"
+  '6 15 double-quoted-argument' # "foo !bar"
   '11 11 history-expansion' # !
-  '12 15 double-quoted-argument' # bar"
 )
index 3e23711..05e20fc 100644 (file)
@@ -33,6 +33,7 @@ expected_region_highlight=(
   "1 4 history-expansion" # !foo
   "6 8 default" # bar
   "10 13 history-expansion" # !baz
-  "15 15 default" # ! (before the semicolon)
-  "19 19 reserved-word" # ! (after the semicolon)
+  "15 15 default" # !
+  "17 17 commandseparator" # ;
+  "19 19 reserved-word" # !
 )
index 484c951..0127b4b 100644 (file)
@@ -31,6 +31,7 @@ PREBUFFER=$'echo "foo1\n'
 BUFFER='foo2" ./'
 
 expected_region_highlight=(
+  "1 5 default" # 'foo2"'
   "1 5 double-quoted-argument" # 'foo2"'
   "7 8 path" # './'
 )
index 8ecce5b..3a90dce 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-BUFFER=$'echo "foo1\n'
+BUFFER=$'echo \'foo1\n'
 
 expected_region_highlight=(
-  "6 10 double-quoted-argument" # 'foo2"'
+  "1 4 builtin" # echo
+  "6 11 default" # 'foo1\n
+  "6 11 single-quoted-argument-unclosed" # 'foo1\n
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/multiple-quotes.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/multiple-quotes.zsh
new file mode 100644 (file)
index 0000000..dabf70c
--- /dev/null
@@ -0,0 +1,42 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2017 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': \'foo\'bar"baz$quux/foo\\\\bar"baz$\'quux\\nfoo\\001bar\'baz'
+
+expected_region_highlight=(
+  "1 1 builtin" # :
+  "3 54 default" # 'foo'bar"baz$quux/foo\\bar"baz$'quux\nfoo\001'baz
+  "3 7 single-quoted-argument" # 'foo'
+  "11 29 double-quoted-argument" #"baz
+  "15 19 dollar-double-quoted-argument" # $quux
+  "24 25 back-double-quoted-argument" # \\
+  "33 51 dollar-quoted-argument" # $'quux\nfoo\001bar'
+  "39 40 back-dollar-quoted-argument" # \n
+  "44 47 back-dollar-quoted-argument" # \001
+)
index 6f3a7f7..5676b5a 100644 (file)
@@ -31,5 +31,7 @@ alias x=command
 BUFFER='x ls'
 
 expected_region_highlight=(
+  "1 1 alias" # x
+  "1 1 precommand" # x (command)
   "3 4 command" # ls
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob-always.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob-always.zsh
new file mode 100644 (file)
index 0000000..481722f
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'{ noglob echo * } always { echo * }'
+
+expected_region_highlight=(
+  '1 1 reserved-word' # {
+  '3 8 precommand' # noglob
+  '10 13 builtin' # echo
+  '15 15 default' # *
+  '17 17 reserved-word' # }
+  '19 24 reserved-word' # always
+  '26 26 reserved-word' # {
+  '28 31 builtin' # echo
+  '33 33 globbing "issue #577"' # *
+  '35 35 reserved-word' # }
+)
index ea70a83..1857db0 100644 (file)
@@ -30,5 +30,9 @@
 BUFFER=':; noglob echo *'
 
 expected_region_highlight=(
+  "1 1 builtin" # :
+  "2 2 commandseparator" # ;
+  "4 9 precommand" # noglob
+  "11 14 builtin" # echo
   "16 16 default" # *
 )
index 6d7a940..3b4fcd7 100644 (file)
 BUFFER='noglob echo *; echo *'
 
 expected_region_highlight=(
+  "1 6 precommand" # noglob
+  "8 11 builtin" # echo
   "13 13 default" # *
+  "14 14 commandseparator" # ;
+  "16 19 builtin" # echo
+  "21 21 default" # *
   "21 21 globbing" # *
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob3.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob3.zsh
new file mode 100644 (file)
index 0000000..c404aaa
--- /dev/null
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+touch \*
+
+BUFFER='noglob echo *'
+
+expected_region_highlight=(
+  "1 6 precommand" # noglob
+  "8 11 builtin" # echo
+  "13 13 path" # *
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob4.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/noglob4.zsh
new file mode 100644 (file)
index 0000000..cc7065f
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$'noglob cat <(print -r -- *)'
+
+expected_region_highlight=(
+  '1 6 precommand' # noglob
+  '8 10 command' # cat
+  '12 27 default' # <(print -r -- *)
+  '12 27 process-substitution' # <(print -r -- *)
+  '12 13 process-substitution-delimiter' # <(
+  '14 18 builtin' # print
+  '20 21 single-hyphen-option' # -r
+  '23 24 double-hyphen-option' # --
+  '26 26 default' # *
+  '26 26 globbing' # *
+  '27 27 process-substitution-delimiter' # )
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/number_range-glob.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/number_range-glob.zsh
new file mode 100644 (file)
index 0000000..c840951
--- /dev/null
@@ -0,0 +1,42 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2017 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='print <-> x<->y <foo2-3>'
+
+expected_region_highlight=(
+  '1 5 builtin' # print
+  '7 9 default' # <->
+  '7 9 globbing' # <->
+  '11 15 default' # x<->y
+  '12 14 globbing' # <->
+  '17 17 redirection' # <
+  '18 23 default' # foo2-3 (the filename)
+  '24 24 redirection' # >
+)
index 550c09f..7d6961a 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-alias a=A
+alias a=:
 f() {}
 
 BUFFER='a;f;'
 
 expected_region_highlight=(
-  "1 1 alias" # f
+  "1 1 alias" # a
+  "1 1 builtin" # a (:)
   "2 2 commandseparator" # ;
-  "3 3 function" # g
+  "3 3 function" # f
   "4 4 commandseparator" # ;
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/option-with-quotes.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/option-with-quotes.zsh
new file mode 100644 (file)
index 0000000..6286f03
--- /dev/null
@@ -0,0 +1,37 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': --user="phy1729"'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 18 double-hyphen-option' # --user="phy1729"
+  '10 18 double-quoted-argument' # "phy1729"
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/order-path-after-dollar.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/order-path-after-dollar.zsh
new file mode 100644 (file)
index 0000000..773c183
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+touch '$foo'
+BUFFER=': $foo \$foo'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 6 default' # $foo - if we add a "unquoted parameter expansion" style then this expectation should change
+  '8 12 path' # \$foo
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/order-path-before-globbing.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/order-path-before-globbing.zsh
new file mode 100644 (file)
index 0000000..8456b18
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2017 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+touch '*'
+BUFFER=': * \*'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 3 default' # *
+  '3 3 globbing' # *
+  '5 6 path' # \*
+)
index 1797e58..2311be0 100644 (file)
@@ -32,5 +32,9 @@ BUFFER='() { : $* }'
 # This tests that $* isn't highlighted as a glob.
 # If we ever add a "unquoted parameter" style, the expectation may change.
 expected_region_highlight=(
+  "1 2 reserved-word" # ()
+  "4 4 reserved-word" # {
+  "6 6 builtin" # :
   "8 9 default" # $*
+  "11 11 reserved-word" # }
 )
index c99f872..baebee3 100644 (file)
@@ -35,6 +35,7 @@ else
   CURSOR=5 # to make path_prefix ineligible
 
   expected_region_highlight=(
+    "1 1 builtin" # :
     "3 16 path" # broken-symlink
   )
 fi
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word.zsh
new file mode 100644 (file)
index 0000000..99055da
--- /dev/null
@@ -0,0 +1,45 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+if [[ $OSTYPE == msys ]]; then
+  skip_test='Cannot chmod +x in msys2' # cargo culted from option-path_dirs.zsh
+else
+  mkdir kappa
+  touch kappa.exe
+  chmod +x kappa.exe
+  cd kappa
+  
+  BUFFER='$PWD.exe; ${PWD}.exe'
+  
+  expected_region_highlight=(
+    "1 8 unknown-token" # $PWD.exe - not eval'd; issue #328
+    "9 9 commandseparator" # ;
+    "11 20 unknown-token" # ${PWD}.exe
+  )
+fi
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word3.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word3.zsh
new file mode 100644 (file)
index 0000000..6921cba
--- /dev/null
@@ -0,0 +1,40 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+# «/usr» at this point would be highlighted as path_prefix; so should
+# a parameter that expands to an equivalent string be highlighted.
+#
+# More complicated parameter substitutions aren't eval'd; issue #328.
+BUFFER='$PWD; ${PWD}'
+
+expected_region_highlight=(
+  "1 4 path" # $PWD
+  "5 5 commandseparator" # ;
+  "7 12 path" # ${PWD}
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word4.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path-dollared-word4.zsh
new file mode 100644 (file)
index 0000000..e29182c
--- /dev/null
@@ -0,0 +1,36 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+# This tests for a regression during development of issue #328: an interim version
+# of that branch failed that test with "Bail out! output on stderr".
+BUFFER='${'
+
+expected_region_highlight=(
+  "1 2 unknown-token" # ${
+)
index cf13dad..52749b7 100644 (file)
@@ -37,17 +37,17 @@ touch A/mu
 BUFFER='ls /bin/ / A/mu A/m'
 
 expected_region_highlight=(
+  "1 2 command"                      # ls
+  "4 8 path"                         # /bin/
   "4 4 path_pathseparator"           # /
-  "5 7 path"                         # bin
   "8 8 path_pathseparator"           # /
 
+  "10 10 path"                       # /
   "10 10 path_pathseparator"         # /
 
-  "12 12 path"                       # A
+  "12 15 path"                       # A/mu
   "13 13 path_pathseparator"         # /
-  "14 15 path"                       # mu
 
-  "17 17 path_prefix"                # A
+  "17 19 path_prefix"                # A/m
   "18 18 path_prefix_pathseparator"  # /
-  "19 19 path_prefix"                # m
 )
index db4e706..bc885a0 100644 (file)
@@ -35,5 +35,6 @@ ZSH_HIGHLIGHT_STYLES[path_pathseparator]=value
 BUFFER='ls /bin/'
 
 expected_region_highlight=(
+  "1 2 command" # ls
   "4 8 path"    # /bin/
 )
index 67a26fd..87cc22f 100644 (file)
@@ -33,5 +33,5 @@ BUFFER='ls A/mu\ with\ spaces'
 
 expected_region_highlight=(
   "1 2  command" # ls
-  "4 19 path"    # A/mu\ with\ spaces
+  "4 21 path"    # A/mu\ with\ spaces
 )
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-ZSH_HIGHLIGHT_STYLES[bracket-level-1]=
-
-BUFFER=': "\"{x"'
+HOME="."
+BUFFER='ls \~'
 
 expected_region_highlight=(
-  "3 9 NONE 'issue #303'"
+  "1 2 command" # ls
+  "4 5 default"    # \~
 )
index 12fb30b..3303bfb 100644 (file)
@@ -33,5 +33,6 @@
 BUFFER='ls /bin/s'
 
 expected_region_highlight=(
-  "4 9 path_prefix"    # /bin/s
+  "1 2 command" # ls
+  "4 9 path_prefix" # /bin/s
 )
index 501928a..4f40f7e 100644 (file)
@@ -34,5 +34,6 @@ BUFFER='ls /bin/s'
 WIDGET=zle-line-finish
 
 expected_region_highlight=(
-  "4 9 default"    # /bin/s
+  "1 2 command" # ls
+  "4 9 default" # /bin/s
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path_prefix3.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/path_prefix3.zsh
new file mode 100644 (file)
index 0000000..f4a0189
--- /dev/null
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2015 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+# Assumes that '/bin/sh' exists and '/bin/s' does not exist.
+# Related to path_prefix.zsh
+
+PREBUFFER='ls \'
+BUFFER='/bin/s'
+
+expected_region_highlight=(
+  '1 6 path_prefix' # /bin/s
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand-unknown-option.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand-unknown-option.zsh
new file mode 100644 (file)
index 0000000..1fba1b9
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+sudo(){}
+
+BUFFER='sudo -ux ls; sudo -x ls'
+
+expected_region_highlight=(
+  '1 4 precommand' # sudo
+  '6 8 single-hyphen-option' # -ux
+  '10 11 command' # ls
+  '12 12 commandseparator' # ;
+  '14 17 precommand' # sudo
+  '19 20 unknown-token' # -x
+  '22 23 command' # ls
+)
index 3d8f332..75dceab 100644 (file)
@@ -31,6 +31,6 @@ BUFFER='command -v ls'
 
 expected_region_highlight=(
   "1 7 precommand" # command
-  "9 10 single-hyphen-option 'issue #343'" # -v
-  "12 13 command 'issue #343'" # ls
+  "9 10 single-hyphen-option" # -v
+  "12 13 command" # ls
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand3.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand3.zsh
new file mode 100644 (file)
index 0000000..f8b0c78
--- /dev/null
@@ -0,0 +1,41 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='nice -n10 ls; nice -n 10 ls'
+
+expected_region_highlight=(
+  "1 4 precommand" # nice
+  "6 9 single-hyphen-option" # -n10
+  "11 12 command" # ls
+  "13 13 commandseparator" # ;
+  "15 18 precommand" # nice
+  "20 21 single-hyphen-option" # -n
+  "23 24 default" # 10
+  "26 27 command" # ls
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand4.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/precommand4.zsh
new file mode 100644 (file)
index 0000000..b9e6119
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+doas(){}
+BUFFER=$'doas -nu phy1729 ls'
+
+expected_region_highlight=(
+  '1 4 precommand' # doas
+  '6 8 single-hyphen-option' # -nu
+  '10 16 default' # phy1729
+  '18 19 command' # ls
+)
index 5a5c0e2..a0f0ed5 100644 (file)
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
-BUFFER='>/tmp >/tmp sudo echo >/tmp foo'
+BUFFER='>/tmp >/tmp command echo >/tmp foo'
 
 expected_region_highlight=(
+  "1  1  redirection" # >
   "2  5  path"       # /tmp
+  "7  7  redirection" # >
   "8  11 path"       # /tmp
-  "13 16 precommand" # sudo
-  "18 21 builtin"    # echo
-  "24 27 path"       # /tmp
-  "29 31 default"    # foo
+  "13 19 precommand" # command
+  "21 24 builtin"    # echo
+  "26 26 redirection" # >
+  "27 30 path"       # /tmp
+  "32 34 default"    # foo
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution-redirection-isnt-globbing.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution-redirection-isnt-globbing.zsh
new file mode 100644 (file)
index 0000000..f8dbd6b
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': =(<foo)'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 9 default' # =(<foo)
+  '3 9 process-substitution' # =(<foo)
+  '3 4 process-substitution-delimiter' # =(
+  '5 5 redirection' # <foo
+  '6 8 default' # foo
+  '9 9 process-substitution-delimiter' # )
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution.zsh
new file mode 100644 (file)
index 0000000..2660034
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': --foo=<(echo bar) "<(:)"'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 19 double-hyphen-option' # --foo=<(echo bar)
+  '9 19 process-substitution' # <(echo bar)
+  '9 10 process-substitution-delimiter' # <(
+  '11 14 builtin' # echo
+  '16 18 default' # bar
+  '19 19 process-substitution-delimiter' # )
+  '21 26 default' # "<(:)"
+  '21 26 double-quoted-argument' # "<(:)"
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution2.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/process-substitution2.zsh
new file mode 100644 (file)
index 0000000..cc55090
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='echo =(:) a=(:) =(echo foo'
+
+expected_region_highlight=(
+  '1 4 builtin' # echo
+  '6 9 default' # =(:)
+  '6 9 process-substitution' # =(:)
+  '6 7 process-substitution-delimiter' # =(
+  '8 8 builtin' # :
+  '9 9 process-substitution-delimiter' # )
+  '11 15 default' # a=(:)
+  '17 26 default' # =(echo foo
+  '17 26 process-substitution' # =(echo foo
+  '17 18 process-substitution-delimiter' # =(
+  '19 22 builtin' # echo
+  '24 26 default' # foo
+)
+
+if [[ ${(z):-'$('} == '$( ' ]]; then # ignore zsh 5.0.8 bug
+  expected_region_highlight[8]='17 27 default' # =(echo foo
+  expected_region_highlight[9]='17 27 process-substitution' # =(echo foo
+fi
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/quoted-command-substitution-empty.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/quoted-command-substitution-empty.zsh
new file mode 100644 (file)
index 0000000..daf3738
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='echo "foo$( '
+
+expected_region_highlight=(
+  '1 4 builtin' # echo
+  '6 12 default' # "foo$(
+  '6 9 double-quoted-argument-unclosed' # "foo
+  '10 12 command-substitution-quoted' # $(
+  '10 11 command-substitution-delimiter-quoted' # $(
+)
+
+if [[ ${(z):-'$('} == '$( ' ]]; then # ignore zsh 5.0.8 bug
+  expected_region_highlight[2]='6 13 default' # "foo$(
+  expected_region_highlight[4]='10 13 command-substitution-quoted' # $(
+fi
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/rc-quotes.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/rc-quotes.zsh
new file mode 100644 (file)
index 0000000..8cd427a
--- /dev/null
@@ -0,0 +1,39 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2017 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+setopt RC_QUOTES
+
+BUFFER=": 'foo''bar'baz"
+
+expected_region_highlight=(
+  "1 1 builtin" # :
+  "3 15 default" # 'foo''bar'baz
+  "3 12 single-quoted-argument" # 'foo''bar'
+  "7 8 rc-quote" # ''
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection-comment.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection-comment.zsh
new file mode 100644 (file)
index 0000000..a019100
--- /dev/null
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2017 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+setopt interactive_comments
+
+BUFFER=': <<#foo'
+
+expected_region_highlight=(
+  "1 1 builtin" # :
+  "3 4 redirection" # <<
+  "5 8 comment" # #foo
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection-in-cmdsubst.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection-in-cmdsubst.zsh
new file mode 100644 (file)
index 0000000..ed5eaef
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=$': $(<foo)'
+
+expected_region_highlight=(
+  '1 1 builtin' # :
+  '3 9 default' # $(<foo)
+  '3 9 command-substitution-unquoted' # $(<foo)
+  '3 4 command-substitution-delimiter-unquoted' # $(
+  '5 5 redirection' # <
+  '6 8 default' # foo
+  '9 9 command-substitution-delimiter-unquoted' # )
+)
index 5086082..6a25971 100644 (file)
@@ -32,5 +32,8 @@ BUFFER='<<<foo echo >>&!bar'
 
 expected_region_highlight=(
   "1 3 redirection" # <<<
+  "4 6 default" # foo
+  "8 11 builtin" # echo
   "13 16 redirection" # >>&!
+  "17 19 default" # bar
 )
index 83f7c08..d44c8e7 100644 (file)
@@ -31,6 +31,11 @@ BUFFER='ls >(wc) | nl'
 
 expected_region_highlight=(
   "1 2 command" # ls
+  "4 8 default" # >(wc)
+  "4 8 process-substitution" # >(wc)
+  "4 5 process-substitution-delimiter" # >(
+  "6 7 command" # wc
+  "8 8 process-substitution-delimiter" # )
   "10 10 commandseparator" # |
   "12 13 command" # nl
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection3.zsh b/.zsh/zsh-syntax-highlighting/highlighters/main/test-data/redirection3.zsh
new file mode 100644 (file)
index 0000000..bf062cf
--- /dev/null
@@ -0,0 +1,42 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2017 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER=': >>>; : <>\<<<<EOF'
+
+expected_region_highlight=(
+  "1 1 builtin" # :
+  "3 4 redirection" # >>
+  "5 5 unknown-token" # >
+  "6 6 commandseparator" # ;
+  "8 8 builtin" # :
+  "10 11 redirection" # <>
+  "12 13 default" # \<
+  "14 16 redirection" # <<<
+  "17 19 default" # EOF
+)
index e71fe0a..aca3796 100644 (file)
@@ -31,6 +31,7 @@ BUFFER='repeat "1" do done'
 
 expected_region_highlight=(
   "1 6 reserved-word" # repeat
+  "8 10 default" # "1"
   "8 10 double-quoted-argument" # "1"
   "12 13 reserved-word" # do
   "15 18 reserved-word" # done
index 0080ad2..c068013 100644 (file)
@@ -31,10 +31,20 @@ BUFFER='tar cf - * | (cd /target; tar xfp -) | { cat }'
 
 expected_region_highlight=(
   "1 3 command" # tar
+  "5 6 default" # cf
+  "8 8 single-hyphen-option" # -
+  "10 10 default" # *
+  "10 10 globbing" # *
+  "12 12 commandseparator" # |
   "14 14 reserved-word" # (
   "15 16 builtin" # cd
+  "18 24 default" # /target
+  "25 25 commandseparator" # ;
   "27 29 command" # tar
+  "31 33 default" # xfp
+  "35 35 single-hyphen-option" # -
   "36 36 reserved-word" # )
+  "38 38 commandseparator" # |
   "40 40 reserved-word" # {
   "42 44 command" # cat
   "46 46 reserved-word" # }
index 3183a23..941349a 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+sudo(){}
+
 # Tests three codepaths:
 # * -i  (no argument)
 # * -C3 (pasted argument)
@@ -41,7 +43,12 @@ expected_region_highlight=(
   "23 24 single-hyphen-option" # -i
   "26 27 command" # ls
   "29 29 path" # /
+  "30 30 commandseparator" # ;
+  "32 35 precommand" # sudo
   "37 37 unknown-token" # ;, error because empty command
+  "39 42 precommand" # sudo
+  "44 45 single-hyphen-option" # -u
   "47 47 unknown-token" # ;, error because incomplete command
+  "49 52 precommand" # sudo
   "54 64 unknown-token" # notacommand - doesn't falls back to "not a command word" codepath
 )
index 856567b..74cd905 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+sudo(){}
+
 setopt interactive_comments
 BUFFER='sudo -u # comment'
 
index f507899..c675d7d 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+sudo(){}
+
 BUFFER='sudo -u >/tmp otheruser ls; sudo ls; sudo -i ls'
 
 expected_region_highlight=(
index 30f6ff8..23ada53 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+sudo(){}
+
 BUFFER='sudo >/tmp -u otheruser ls'
 
 expected_region_highlight=(
index fdd426d..80e55b5 100644 (file)
@@ -27,6 +27,8 @@
 # vim: ft=zsh sw=2 ts=2 et
 # -------------------------------------------------------------------------------------------------
 
+sudo(){}
+
 BUFFER='sudo 2>./. -u otheruser ls'
 
 expected_region_highlight=(
index 4b77766..7003c49 100644 (file)
@@ -34,5 +34,10 @@ CURSOR=4
 MARK=12
 
 expected_region_highlight=(
-  "1 3 standout" # foo
+  "1 3 unknown-token" # foo
+  "5 7 default" # foo
+  "8 8 commandseparator" # \n
+  "9 11 unknown-token" # bar
+  "13 15 default" # bar
+  "1 15 standout" # foo foo\nbar bar
 )
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/regexp/README.md b/.zsh/zsh-syntax-highlighting/highlighters/regexp/README.md
new file mode 120000 (symlink)
index 0000000..9f2522d
--- /dev/null
@@ -0,0 +1 @@
+../../docs/highlighters/regexp.md
\ No newline at end of file
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/regexp/regexp-highlighter.zsh b/.zsh/zsh-syntax-highlighting/highlighters/regexp/regexp-highlighter.zsh
new file mode 100644 (file)
index 0000000..26f9da3
--- /dev/null
@@ -0,0 +1,62 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+
+# List of keyword and color pairs.
+typeset -gA ZSH_HIGHLIGHT_REGEXP
+
+# Whether the pattern highlighter should be called or not.
+_zsh_highlight_highlighter_regexp_predicate()
+{
+  _zsh_highlight_buffer_modified
+}
+
+# Pattern syntax highlighting function.
+_zsh_highlight_highlighter_regexp_paint()
+{
+  setopt localoptions extendedglob
+  local pattern
+  for pattern in ${(k)ZSH_HIGHLIGHT_REGEXP}; do
+    _zsh_highlight_regexp_highlighter_loop "$BUFFER" "$pattern"
+  done
+}
+
+_zsh_highlight_regexp_highlighter_loop()
+{
+  local buf="$1" pat="$2"
+  integer OFFSET=0
+  local MATCH; integer MBEGIN MEND
+  local -a match mbegin mend
+  while true; do
+    [[ "$buf" =~ "$pat" ]] || return;
+    region_highlight+=("$((MBEGIN - 1 + OFFSET)) $((MEND + OFFSET)) $ZSH_HIGHLIGHT_REGEXP[$pat]")
+    buf="$buf[$(($MEND+1)),-1]"
+    OFFSET=$((MEND+OFFSET));
+  done
+}
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/complex.zsh b/.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/complex.zsh
new file mode 100644 (file)
index 0000000..4e0089b
--- /dev/null
@@ -0,0 +1,37 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+ZSH_HIGHLIGHT_REGEXP+=('[0-9\+\-]+' 'fg=white,bold,bg=red')
+
+BUFFER='echo 1+9-3 7+2'
+
+expected_region_highlight=(
+  "6 10 fg=white,bold,bg=red"
+  "12 14 fg=white,bold,bg=red"
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/subexpression.zsh b/.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/subexpression.zsh
new file mode 100644 (file)
index 0000000..308cb41
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env zsh
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2018 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+BUFFER='ls foo'
+ZSH_HIGHLIGHT_REGEXP=('(^| )(ls|cd)($| )' 'fg=green')
+
+expected_region_highlight=(
+  '1 3 fg=green' # "ls "
+)
diff --git a/.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/word-boundary.zsh b/.zsh/zsh-syntax-highlighting/highlighters/regexp/test-data/word-boundary.zsh
new file mode 100644 (file)
index 0000000..1f4f666
--- /dev/null
@@ -0,0 +1,42 @@
+# -------------------------------------------------------------------------------------------------
+# Copyright (c) 2016 zsh-syntax-highlighting contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, are permitted
+# provided that the following conditions are met:
+#
+#  * Redistributions of source code must retain the above copyright notice, this list of conditions
+#    and the following disclaimer.
+#  * Redistributions in binary form must reproduce the above copyright notice, this list of
+#    conditions and the following disclaimer in the documentation and/or other materials provided
+#    with the distribution.
+#  * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
+#    may be used to endorse or promote products derived from this software without specific prior
+#    written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# -------------------------------------------------------------------------------------------------
+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
+# vim: ft=zsh sw=2 ts=2 et
+# -------------------------------------------------------------------------------------------------
+
+if zmodload zsh/pcre 2>/dev/null; then
+  setopt RE_MATCH_PCRE
+
+  ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' 'fg=white,bold,bg=red')
+
+  BUFFER='sudo ls'
+
+  expected_region_highlight=(
+    "1 4 fg=white,bold,bg=red"
+  )
+else
+  skip_test='Test requires zsh/pcre'
+fi
index 78433c3..8487b3c 100644 (file)
@@ -13,12 +13,13 @@ The value of that parameter is a list of strings of the form  `"$i $j $style"`.
 or `"$i $j $style $todo"`.
 Each string specifies the highlighting that `$BUFFER[$i,$j]` should have;
 that is, `$i` and `$j` specify a range, 1-indexed, inclusive of both endpoints.
-`$style` is either a key of `$ZSH_HIGHLIGHT_STYLES` or `NONE` to specify no
-highlighting should be observed.
+`$style` is a key of `$ZSH_HIGHLIGHT_STYLES`.
 If `$todo` exists, the test point is marked as TODO (the failure of that test
 point will not fail the test), and `$todo` is used as the explanation.
 If a test sets `$skip_test` to a non-empty string, the test will be skipped
 with the provided string as the reason.
+If a test sets `unsorted=1` the order of highlights in `$expected_region_highlight`
+need not match the order in `$region_highlight`.
 
 **Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but
 interprets the indexes differently.
index eb24934..f3dc84e 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env zsh
 # -------------------------------------------------------------------------------------------------
-# Copyright (c) 2015 zsh-syntax-highlighting contributors
+# Copyright (c) 2015, 2017 zsh-syntax-highlighting contributors
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without modification, are permitted
index a7b98a5..812b1a7 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/env zsh
 # -------------------------------------------------------------------------------------------------
-# Copyright (c) 2010-2016 zsh-syntax-highlighting contributors
+# Copyright (c) 2010-2017 zsh-syntax-highlighting contributors
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without modification, are permitted
@@ -92,21 +92,21 @@ run_test_internal() {
 
   local tests_tempdir="$1"; shift
   local srcdir="$PWD"
-  builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! cd failed: $?"; return 1 }
+  builtin cd -q -- "$tests_tempdir" || { echo >&2 "Bail out! On ${(qq)1}: cd failed: $?"; return 1 }
 
   echo "# ${1:t:r}"
 
   # Load the data and prepare checking it.
-  local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET skip_test
+  local BUFFER CURSOR MARK PENDING PREBUFFER REGION_ACTIVE WIDGET skip_test unsorted=0
   local -a expected_region_highlight region_highlight
   . "$srcdir"/"$1"
 
   (( $#skip_test )) && { print -r -- "1..0 # SKIP $skip_test"; return; }
 
   # Check the data declares $PREBUFFER or $BUFFER.
-  [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; }
+  [[ -z $PREBUFFER && -z $BUFFER ]] && { echo >&2 "Bail out! On ${(qq)1}: Either 'PREBUFFER' or 'BUFFER' must be declared and non-blank"; return 1; }
   # Check the data declares $expected_region_highlight.
-  (( ${#expected_region_highlight} == 0 )) && { echo >&2 "Bail out! 'expected_region_highlight' is not declared or empty."; return 1; }
+  (( $+expected_region_highlight == 0 )) && { echo >&2 "Bail out! On ${(qq)1}: 'expected_region_highlight' is not declared."; return 1; }
 
   # Set sane defaults for ZLE variables
   : ${CURSOR=$#BUFFER} ${PENDING=0} ${WIDGET=z-sy-h-test-harness-test-widget}
@@ -114,54 +114,48 @@ run_test_internal() {
   # Process the data.
   _zsh_highlight
 
-  # Overlapping regions can be declared in region_highlight, so we first build an array of the
-  # observed highlighting.
-  local i j
-  local -A observed_result
-  for ((i=1; i<=${#region_highlight}; i++)); do
-    local -a highlight_zone; highlight_zone=( ${(z)region_highlight[$i]} )
-    integer start=$highlight_zone[1] end=$highlight_zone[2]
-    if (( start < end )) # region_highlight ranges are half-open
+  if (( unsorted )); then
+    region_highlight=("${(@n)region_highlight}")
+    expected_region_highlight=("${(@n)expected_region_highlight}")
+  fi
+
+  echo "1..$(( $#expected_region_highlight + 1))"
+  local i
+  for ((i=1; i<=$#expected_region_highlight; i++)); do
+    local -a expected_highlight_zone; expected_highlight_zone=( ${(z)expected_region_highlight[i]} )
+    integer exp_start=$expected_highlight_zone[1] exp_end=$expected_highlight_zone[2]
+    local todo=
+    (( $+expected_highlight_zone[4] )) && todo="# TODO $expected_highlight_zone[4]"
+    if ! (( $+region_highlight[i] )); then
+      print -r -- "not ok $i - unmatched expectation ($exp_start $exp_end $expected_highlight_zone[3])"
+      continue
+    fi
+    local -a highlight_zone; highlight_zone=( ${(z)region_highlight[i]} )
+    integer start=$(( highlight_zone[1] + 1 )) end=$highlight_zone[2]
+    # Escape # as ♯ and newline as ↵ they are illegal in the 'description' part of TAP output
+    local desc="[$start,$end] «${${BUFFER[$start,$end]//'#'/♯}//$'\n'/↵}»"
+    if
+      [[ $start != $exp_start ]] ||
+      [[ $end != $exp_end ]] ||
+      [[ $highlight_zone[3] != $expected_highlight_zone[3] ]]
     then
-      (( --end )) # convert to closed range, like expected_region_highlight
-      (( ++start, ++end )) # region_highlight is 0-indexed; expected_region_highlight is 1-indexed
-      for j in {$start..$end}; do
-        observed_result[$j]=$highlight_zone[3]
-      done
+      print -r -- "not ok $i - $desc - expected ($exp_start $exp_end ${(qqq)expected_highlight_zone[3]}), observed ($start $end ${(qqq)highlight_zone[3]}). $todo"
     else
-      # noop range; ignore.
+      print -r -- "ok $i - $desc${todo:+ - }$todo"
     fi
-    unset start end
-    unset highlight_zone
-  done
-
-  # Then we compare the observed result with the expected one.
-  echo "1..${#expected_region_highlight}"
-  for ((i=1; i<=${#expected_region_highlight}; i++)); do
-    local -a highlight_zone; highlight_zone=( ${(z)expected_region_highlight[$i]} )
-    local todo=
-    integer start=$highlight_zone[1] end=$highlight_zone[2]
-    # Escape # as ♯ since the former is