Compare commits

...

326 Commits

Author SHA1 Message Date
Matthew Martin
e0165eaa73 main: Refactor __is_redirection
Fixes #942.
2024-01-06 12:36:52 -06:00
Matthew Martin
dcc99a8649 Post-release version number bump. 2023-12-18 16:07:39 -06:00
Matthew Martin
db085e4661 Tag version 0.8.0. 2023-12-18 16:05:43 -06:00
Matthew Martin
9bb3db7fd2 driver: Use stable zsh release in is-at-least calls 2023-12-18 16:02:40 -06:00
Matthew Martin
bb27265aee CI: Update action versions 2023-10-29 13:25:08 -05:00
Matthew Martin
71bd576af8 CI += zsh 5.9 2023-10-29 13:13:49 -05:00
Matthew Martin
d59ce0fbd0 driver: Be resilient to KSH_ARRAYS being set in the calling scope 2023-10-29 12:53:19 -05:00
Matthew Martin
e82e2d042d main: precommand_options += ktrace 2023-10-29 12:50:08 -05:00
m0viefreak
0b5b3dcc0c tests: parameter-to-global-alias: Use alias name less likely to clash 2023-10-27 22:05:00 -05:00
Matthew Martin
f8cd0b55b3 docs: Replace zplug instructions with zinit
Fixes #883.
2023-10-25 22:36:04 -05:00
Matthew Martin
1e82d8c83e changelog: Update through HEAD 2023-10-25 22:11:43 -05:00
Matthew Martin
dd0cf649d1 *: Use https in URLs 2023-10-25 21:33:29 -05:00
Mario P. Cardenas
65071902d3 docs: add instructions to source .zshrc file after package install 2023-10-24 21:15:46 -05:00
Matthew Martin
143b25eb98 docs: Fix Homebrew link
Closes #937.
2023-09-05 23:23:07 -05:00
Henry Bley-Vroman
1386f1213e docs: ZSH_HIGHLIGHT_HIGHLIGHTERS is (main) by default 2023-06-02 22:24:20 -06:00
Johan van Eck
754cefe018 docs: Markup changes only (in the brew installation instructions) 2023-02-05 08:49:34 +00:00
DiegoBoy
75ba3d87e3 Fix proxychains args
Args for proxychains should be f:q => -f file  : -q quiet.

From comments in the same function:
# $precommand_options maps precommand name to values of $flags_with_argument,
# $flags_sans_argument, and flags_solo for that precommand, joined by a
# colon.
2023-02-02 14:57:36 +00:00
Matthew Martin
b2c910a85e docs: Add Fig instructions
Closes #877
2022-11-19 14:30:47 -06:00
Matthew Martin
122dc46439 main: Add cpulimit to precommands
Closes #897
2022-09-23 19:33:44 -05:00
inventor500
b828f45da6 main precommands += torsocks 2022-09-24 00:28:28 +00:00
Daniel Shahaf
caa749d030 main: Housekeep $precommand_options. Add -v to tabbed(1). 2022-05-14 18:48:13 +00:00
Daniel Shahaf
c5ce001467 main: Deconfuse $EDITOR
Work around <https://github.com/chrisbra/vim-zsh/issues/33>.
2022-02-23 18:48:13 +00:00
Daniel Shahaf
5459ebcc4e main: precommand_options += grc 2022-02-23 18:19:58 +00:00
Daniel Shahaf
2cd73fcbde *: Update sourceforge links
* changelog.md: Update links here too.  They have not yet appeared in
    any stable release.

Command used: perl -pi -e 's#http://zsh.sourceforge.net#https://zsh.sourceforge.io#g' **/*(.)
2022-02-22 10:42:31 +00:00
Daniel Shahaf
643717ccaf changelog: Update zsh version numbers
5.8.0.3 was correct until 5.8.1 was released (see the great-grandparent of this
commit, "driver: Bump the in-development is-at-least checks so they return
false on zsh 5.8.1, released yesterday").

5.2 -> 5.3 is simply a typo fix.  zle-line-pre-redraw has been available since then.
2022-02-22 10:38:45 +00:00
Nuri Jung
caeca0bf6b docs: regexp: Document the platform dependency
Patch by Nuri Jung; extension to cover PCRE by me.  See #747.

Fixes #747.
2022-02-22 10:34:43 +00:00
Daniel Shahaf
56b4433461 CI += zsh 5.8.1 2022-02-13 21:33:05 +00:00
Daniel Shahaf
0ddb1a8d51 driver: Bump the in-development is-at-least checks so they return false on zsh 5.8.1, released yesterday.
Fixes #856
Fixes #857
2022-02-13 18:03:11 +00:00
Daniel Shahaf
c10808ad5f main: New test for issue #854 2022-01-31 09:54:57 +00:00
Daniel Shahaf
b392045e6f driver: Simplify grammar of a comment. No functional change. 2022-01-31 09:54:57 +00:00
Daniel Kuettel
c7caf57ca8 check KEYS_QUEUED_COUNT and PENDING to skip parsing when pasting 2021-11-14 02:45:00 +00:00
Leonardo Gama
1a9264bc66 docs: Add regexp to the list of built-in highlighters 2021-09-24 00:40:57 -03:00
Leonardo Gama
f6a22fa842 docs: Change highlighters' URL indexes from numbers to labels 2021-09-24 00:40:39 -03:00
a1346054
6e0e950154 *: Fix spelling
Part of PR #832.
2021-08-20 11:30:10 +00:00
Matthew Martin
dffe304567 CI: Pull image from the GitHub container registry 2021-07-03 14:33:17 -05:00
Matthew Martin
f0e6a8ef5c main: Honor shwordsplit when expanding parameters
Closes #687, #818.
2021-06-28 23:02:31 -05:00
Matthew Martin
0e1bb14452 main: precommands += proxychains 2021-05-29 23:24:58 -05:00
Matthew Martin
894127b221 docs,CI: Switch to Libera.Chat 2021-05-20 20:10:34 -05:00
Daniel Shahaf
ebef4e5569 docs: Use SSL for the link to zsh's homepage. 2021-04-14 10:39:18 +00:00
Robert
993a07fc7f docs: Fix broken link to fish shell 2021-04-14 10:39:18 +00:00
Nikola Knezevic
e8517244f7 main: Allow for "]" in shell aliases
PR #776 fixed an issue with complex aliases and expansion. However, this change
also introduced a problem with aliases which contain `]` (for example, commonly
seen on macOS: `alias ]=open`), due to using an associative array `seen_alias`,
indexed by the alias name. Due to `"$seen_alias[$arg]"`, it would fail when
`$arg` is expanded to anything containing `]`'. Thus, typing `] /` would result
in:

```
> ] /
(anon):unset:3: seen_alias[]]: invalid parameter name
```

This change fixes the issue by ensuring we properly access keys in the
associative array `seen_alias`.

Older versions of zsh have issues with map keys having special
characters, especially lacking ways to remove such keys. The
issue is described in detail in
https://unix.stackexchange.com/questions/626393/in-zsh-how-do-i-unset-an-arbitrary-associative-array-element.

This fix uses proposal from
[zsh-workers/43269](https://www.zsh.org/mla/workers/2018/msg01073.html),
discovered by Stephane Chazelas, that boils down to avoid removing keys
from the map, and reconstruct the map anew with some keys omitted.

Co-authored-by: @phy1729
2021-03-04 20:29:43 -06:00
Daniel Shahaf
205bc7ea19 'main': Disable a lint warning when env(1) was followed by a pipe.
Fixes #797.
2021-03-01 20:21:39 +00:00
Matthew Martin
5eb494852e Switch to GitHub Actions from Travis 2020-12-25 16:43:50 -06:00
Matthew Martin
75c0eb0717 main: Remember nest level an alias was seen in for seen_alias
Fixes #775.
2020-12-25 16:39:07 -06:00
Matthew Martin
046cb03a12 main: Convert in_alias to an array of shift counts
No functional change. Keeps track of how deep we are in expanding nested
aliases for the next commit.
2020-12-25 16:39:07 -06:00
Hussaina Begum Nandyala
1715f39a46 docs: Add resource link for NetBSD operating system
Signed-off-by: Hussaina Begum Nandyala <hexxdump@gmail.com>
2020-11-02 12:18:01 -06:00
Matthew Martin
2ebfa6a598 main: Forget seen aliases when starting a new command
Fixes #769
2020-10-12 19:29:53 -05:00
Matthew Martin
aac09942b8 Revert "tests: Add a test that 'rehash' isn't run."
This reverts commit 62c5575848.

The test fails when zsh/parameter is available.
2020-10-12 19:28:53 -05:00
Roman Perepelitsa
62c5575848 tests: Add a test that 'rehash' isn't run.
See comments within for the rationale.

This is a regression test for a regression that was only present in development
versions of PR #764 and was never present in master.
2020-08-26 08:47:06 +00:00
Ivo Šmerek
4cf464f843 docs: Update Gentoo link 2020-08-16 13:12:46 +00:00
Daniel Shahaf
6d5372a937 tests: parameter-to-global-alias: Fix a false positive failure when 'x' happens to be a valid external command name.
Reported on issue #757 along with other issues.
2020-08-11 09:21:21 +00:00
Daniel Shahaf
e9cad1493f changelog: Document #712 under the last tag, 0.8.0-alpha1-pre-redrawhook. 2020-08-11 08:42:59 +00:00
m0viefreak
79b6e7e05f tests: precommand-killing1: Use a dummy path that always exists
E.g., on Cygwin /etc/passwd does not necessarily exist.
2020-08-11 08:13:17 +00:00
Daniel Shahaf
3944a44ffe driver: Fix a version number check to work around a bug in the zsh version whereunder the check should return false.
The bug is as follows:

    % zsh-5.8 -fc 'autoload is-at-least; is-at-least 5.8.0.2 && echo yes || echo no'
    yes
    % zsh-5.8 -fc 'autoload is-at-least; is-at-least 5.8.0.2 $ZSH_VERSION && echo yes || echo no'
    yes

This commit deploys the following workaround:

    % zsh-5.8 -fc 'autoload is-at-least; is-at-least 5.8.0.2 $ZSH_VERSION.0.0 && echo yes || echo no'
    no

Fixes #756.
2020-08-10 07:40:01 +00:00
Matthew Martin
34674d7860 docs: Add OpenBSD port 2020-08-09 13:08:29 -05:00
Matthew Martin
e4d1db1e2c docs: Sort INSTALL.md 2020-08-09 13:08:29 -05:00
Daniel Shahaf
c14fcad3b0 empty commit: Close redrawhook bugs
The parent commit, which merged the feature/redrawhook bug and thereby
closed PR #749, also fixed the following issue:

Fixes #40.

Fixes #90, closes #470. (The latter is a PR for the former.)

Fixes #150, closes #151, closes #160. (The latter two are PR's for the first one.) The related issue #183 appears to have been fixed in master. For #150, a different fix for older versions of zsh was considered but has not been implemented.

Issue #154 was fixed in xsel(1) in 2017. The parent commit probably fixed that issue for pre-2017 xsel(1).

Is #245, #356, and #749. Fixes #245 (redrawhook umbrella issue).

Does not reintroduce #257 (comment).

Does not reintroduce #259 (comment)

Closes #281 as obsolete.

Fixes #295.

Fixes #324.

Fixes #375.

Fixes #377.

Closes #421 as obsolete.

Fixes #520.

Unblocks #536 (already milestoned).

Fixes #632.

Unblocks #635. Milestoned.

Unblocks #688. Milestoned.

Unblocks administrative issue #655 (already milestoned).

(The above is copied from
https://github.com/zsh-users/zsh-syntax-highlighting/pull/749#issuecomment-658407330,
but repeated here for the sake of github's commit-to-issue linking magic.)
2020-08-09 11:09:19 +00:00
Daniel Shahaf
239c720dec Merge branch 'feature/redrawhook'
* feature/redrawhook:
  docs: Track making the new codepath conditional upon the 'memo=' feature.
  On the feature/redrawhook branch, changelog: Add entries for issues fixed by this branch.
  On the feature/redrawhook branch, change the detection of the 'memo=' feature to avoid a catch-22.
  driver: Make the redrawhook codepath conditional upon the memo= feature.
  On the feature/redrawhook branch, move the changelog entry to the current release's section.
  driver: Fix a bug that prevented subsequent, third-party zle-line-pre-redraw hooks from running.
  driver: Do not pass widget arguments to _zsh_highlight
  driver: Clarify comment.  No functional change.
  driver: Allow for -U in autoloaded function definition
  driver: Use idiomatic module check
  driver: Make the shadowing $WIDGET read only.
  driver: Avoid a fork in the common case.
  test harness: Actually test the new code.
  driver: Rewrite without a state variable
  noop: Make a whitespace-only change to reduce noise in the next commit.
  docs: Rewrap.
  docs: Update FAQ answer per changes on this branch.
  redo _zsh_highlight__function_callable_p
  driver: Use a different way of checking whether add-zle-hook-widget is present.
  changelog: Use a more specific link.
  changelog: Note the effect of fixing #245/#90 and an alternative.
  driver: Pass zle-line-finish arguments on to _zsh_highlight.
  driver: Hook zle-line-finish.
  driver: Reimplement using 'add-zle-hook-widget zle-line-pre-redraw'
  wrappers: Reimplement using Mikachu's zle-line-pre-redraw hook (workers/36650).
2020-08-09 11:00:45 +00:00
Daniel Shahaf
7cc6226477 docs: Track making the new codepath conditional upon the 'memo=' feature.
The new codepath is used in 5.8.0.2 and newer; see zsh-syntax-highlighting.zsh:417.
2020-08-09 10:56:18 +00:00
Daniel Shahaf
cba4a1bc2e On the feature/redrawhook branch, changelog: Add entries for issues fixed by this branch.
This covers issues referenced from #245 or labelled "feature:redrawhook" or "widget-wrapping".  See #749 for details.
2020-07-14 23:20:29 +00:00
Daniel Shahaf
637e1c702e Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master:
  Post-release version number bump.
  Tag version 0.8.0-alpha1-pre-redrawhook.
  brackets: Optimize the character iteration
2020-07-14 22:49:17 +00:00
Daniel Shahaf
2d60a47cc4 Post-release version number bump. 2020-07-14 21:33:52 +00:00
Daniel Shahaf
00a5fd11eb Tag version 0.8.0-alpha1-pre-redrawhook. 2020-07-14 21:31:39 +00:00
Daniel Shahaf
cdd7f899cb brackets: Optimize the character iteration
Test case: See the first comment of issue #295.

Before:
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)   14         284.67    20.33   82.84%    284.67    20.33   82.84%  _zsh_highlight_highlighter_brackets_paint
 2)   15         313.72    20.91   91.30%     26.62     1.77    7.75%  _zsh_highlight
 3)   14         318.68    22.76   92.74%      7.41     0.53    2.16%  _zsh_highlight_call_widget

After:
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)   15          57.25     3.82   45.33%     28.30     1.89   22.41%  _zsh_highlight
 2)   14          81.96     5.85   64.90%     27.02     1.93   21.40%  _zsh_highlight_call_widget
 3)   14          26.31     1.88   20.84%     26.31     1.88   20.84%  _zsh_highlight_highlighter_brackets_paint
 4)    2          10.66     5.33    8.44%      8.97     4.49    7.10%  VCS_INFO_formats
 5)    2          25.92    12.96   20.52%      7.72     3.86    6.11%  VCS_INFO_get_data_git

(That's not in my everyday configuration but in my minimal testing
setup, which runs vcs_info with the default settings.)
2020-07-14 20:19:40 +00:00
Daniel Shahaf
cb33cc0081 On the feature/redrawhook branch, change the detection of the 'memo=' feature to avoid a catch-22. 2020-07-14 02:37:41 +00:00
Daniel Shahaf
9ce3540d74 Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master:
  Revert "driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function."
2020-07-14 02:31:24 +00:00
Daniel Shahaf
d62baa50f4 Revert "driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function."
This reverts commit 8a1bd7c8b6.

The detection only works correctly from a widget function, so the change
was wrong: it caused zsh_highlight__memo_feature to be set to false
every time.
2020-07-14 02:29:46 +00:00
Daniel Shahaf
59cb9a560d driver: Make the redrawhook codepath conditional upon the memo= feature.
Fixes #579 (zsh-autosuggestions interoperability).
Fixes #735 (ditto).

See https://github.com/zsh-users/zsh-syntax-highlighting/issues/579#issuecomment-650126055
See https://github.com/zsh-users/zsh-autosuggestions/issues/529#issuecomment-650481227
2020-07-14 02:13:51 +00:00
Daniel Shahaf
7b863fb413 Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master:
  driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function.
2020-07-14 02:08:20 +00:00
Daniel Shahaf
8a1bd7c8b6 driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function.
This is needed for feature/redrawhook to be able to use it.
2020-07-14 02:07:32 +00:00
Daniel Shahaf
daf0d94bae On the feature/redrawhook branch, move the changelog entry to the current release's section. 2020-07-14 02:00:45 +00:00
Daniel Shahaf
c28312b9d3 Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master: (297 commits)
  driver: Follow-up to grandparent: Have all test suite entry points declare the mock $region_highlight.
  Use the new, unreleased zsh 'memo=' feature to remove only our own entries from $region_highlight.
  driver: Stop re-declaring $region_highlight.  It's unneeded.
  docs: regexp highlighter: Fix a wrong associative array name in the example.
  docs: Fix obs-repository link
  tests: Fix a wrong value of $PREBUFFER in a test, and add checks to prevent this from recurring.
  test harness: Fix use of an undefined variable in an error message.
  'main': Don't progress the $in_redirection staller while $in_param.
  tests: Add an XFail test for issue #712.
  'main': Highlight the parentheses of array assignments as reserved words.
  CI += zsh-5.8
  main: Add tests for arithmetic expansion
  main: Add arithmetic substitution highlighting
  changelog.md: Restore vertical whitespace before section headers.
  'main': Fix issue #677, concerning multiline aliases.
  changelog: Update through HEAD.
  'main': Further optimize argument parsing.
  'main': Optimize a hot path.
  tests: Add a performance testing script, for measuring the performance of the 'main' highlighter on a large file.
  changelog: Update through HEAD.
  test harness: Print the expected-v.-actual on every failure, not just upon cardinality failures.
  Document ZSH_HIGHLIGHT_MAXLENGTH.
  'main': Fix the last commit's bug concerning parameter elision not happening in redirects in command position.
  'main': Add a test for parameter elision not happening in redirects in command position.
  'main': Fix regression in zsh 5.3.1 and older: all precmd hooks later than z-sy-h would be aborted.
  changelog += WARN_NESTED_VAR fixes (#727, #731)
  'main': Fix a regression caused by the great-grandparent commit's WARN_NESTED_VAR fix.
  'main': Don't run `_zsh_highlight_main__type` on every non-command word.
  'make perf': Show only a cumulative datum per highligher, rather than per test file.
  'main': Don't trip WARN_NESTED_VAR.
  'main': Follow-up to previous: Document the version number, and deduplicate some option letters.
  'main': precommands += strace
  editorconfig: Fix Makefile settings
  Fix typo
  Bump copyright years.
  driver: Fix "_zsh_highlight:3: read-only variable: ret" warnings when POSIX_BUILTINS is set.
  tests: Add a test for the infinite loop fixed by each of the last two commits.
  'main': Fix expansion of positional parameters in `_zsh_highlight_main_highlighter__try_expand_parameter`.
  'main': Fix an infinite loop.
  'main': precommands += ionice(1) (from util-linux)
  driver: Simplify initialization of $zsyh_user_options in the fallback codepath.
  driver: Make sure we don't change the return value in a called function.
  'main': Make logic more robust.  No functional change.
  'main': Break out an anonymous function into a named function.
  Fix typos in comments.
  main: Add test for issue #713
  'main': Support the 'env' precommand.
  test harness: Fix the pretty-printer's padding implementation.
  Revert "test harness: Rewrite the columnar pretty-printer without external tools." and "travis: Remove bsdmainutils since column(1) has been removed, three commits ago."
  changelog: Update through HEAD.
  'main': Correctly highlight '&&' and '||' inside '[[ … ]]' conditions.
  'main': Highlight reserved words following assignments as errors.
  tests: Add tests for issue #461.
  test harness: Output the time information to the same place the test name was printed to.
  test harness: Stringify values in a more readable manner.
  tests: Add a unit test for a path specified with mixed quoting.
  tests: Add a test for issue #498, which has already been fixed.
  tests: Test that global qualifiers and command substitutions aren't evaluated.
  'main': Don't consider path_prefix in alias expansions.
  'main': Add a test for aliases to AUTO_CD directories.
  'main': Let AUTO_CD directories be highlighted with their own style.
  'main': Add an auxiliary variable for readability.
  'main': In command position, do not highlight directories (unless AUTO_CD is set) and non-executable files.
  'main': Extend tests to capture the current behaviour.
  'main': Add an XFail test for issue #202.
  'main': Highlight errors from the EQUALS option.
  'main': Let the type determination ignore global aliases when it ignores regular ones.
  'main': Add a regression test for parameters that expand to global aliases.
  'main': Enable the zsh/parameter codepath of global aliases highlighting.
  changelog: Update through HEAD.
  travis: Remove bsdmainutils since column(1) has been removed, three commits ago.
  'main': Highlight global aliases
  tests: Record current behaviour on global aliases.
  test harness: Rewrite the columnar pretty-printer without external tools.
  test harness: Fix an issue with the pretty-printed $expected_region_highlight/$region_highlight diffing.
  'main': Support the "close file descriptor" and "coproc" redirection syntaxes
  tests: Add a test for the "close file descriptor" and "coproc" redirection syntaxes
  tests: Fix the test added in the last commit.
  tests: Add a test for issue #705, concerning continuation lines.
  test harness: Let tests fail early by exiting non-zero or by setting a flag.
  test harness: Print the test name when $skip_test is set.
  test harness: Remove a bogus check.
  test harness: Fix $skip_test support, broken yesterday.
  travis: Install bsdmainutils to provide column(1).
  test harness: When the cardinality check fails, pretty-print \$expected_region_highlight and \$region_highlight.
  test harness: Don't leak options from test files to the test harness.
  test harness: Fix test failures under zsh 5.0.8 and older.
  'main': Fix a bug manifesting under zsh 5.2 and older.
  'main': Don't highlight arithmetic expansions as command substitutions.
  tests: Add a test documenting the current state, prior to introducing #704.
  test harness: Change cardinality check semantics
  test harness: No-op change to minimize the next diff.
  'main': Document additional meanings of the 'S' $braces_stack flag.
  'main': When the redirection operator '>&' or '<&' is followed by a positive integer, do not consider that as a filename; it's always a file descriptor.
  'main': Add $last_arg for "lookbehind".
  noop: Clarify comment.
  'main': Honour the MULTIOS option when applying the 'globbing' style.
  'main': Document what $in_redirection is currently used for.
  'main': The optimized cmdsubst input syntax doesn't glob.
  changelog: Fix markup.
  ...
2020-07-14 01:57:55 +00:00
Daniel Shahaf
d9a7963970 driver: Follow-up to grandparent: Have all test suite entry points declare the mock $region_highlight.
tests/generate.zsh already does this.
2020-07-14 01:57:02 +00:00
Daniel Shahaf
810c2dcede Use the new, unreleased zsh 'memo=' feature to remove only our own entries from $region_highlight.
Fixes #418 (interoperability issue with other plugins).
2020-07-14 00:32:36 +00:00
Daniel Shahaf
075c852924 driver: Stop re-declaring $region_highlight. It's unneeded. 2020-07-14 00:32:36 +00:00
Nuri Jung
fb929edc30 docs: regexp highlighter: Fix a wrong associative array name in the example.
Factored out from #747.
2020-07-01 12:55:43 +00:00
Il Harper
91d2eeaf23 docs: Fix obs-repository link 2020-06-15 00:23:05 -05:00
Daniel Shahaf
f6471dbec3 tests: Fix a wrong value of $PREBUFFER in a test, and add checks to prevent this from recurring.
Discussed: https://github.com/zsh-users/zsh-syntax-highlighting/pull/706#issuecomment-642072978
2020-06-11 08:14:07 +00:00
Daniel Shahaf
f6f7a91818 test harness: Fix use of an undefined variable in an error message.
The error message uses «$1», but it is always unset at that point.
Furthermore, the NO_UNSET (-u) option is in effect.  Therefore, when the
error message was to be printed, zsh's NO_UNSET error message was
printed instead:
.
    (anon):20: 1: parameter not set

That error message was printed to stderr, and was caught by the caller
within the test harness:
.
    Bail out! On './highlighters/main/test-data/path_prefix3.zsh': output on stderr

Thus, the bug being fixed would not caused false positive or false
negative test results, but only wrong error messages.

Follow-up to 0.7.1-71-ge6eea1f, "test harness: Don't leak options from
test files to the test harness".
2020-06-11 08:09:45 +00:00
Daniel Shahaf
6fd92e1bbd 'main': Don't progress the $in_redirection staller while $in_param.
Fixes #712.
2020-06-08 14:38:59 +00:00
Daniel Shahaf
792c065acb tests: Add an XFail test for issue #712.
The second test point passes on 0.7.1, but the third does not.
2020-06-08 14:38:43 +00:00
Daniel Shahaf
0f11d80968 'main': Highlight the parentheses of array assignments as reserved words.
Fixes #585.
2020-06-08 14:23:43 +00:00
Daniel Shahaf
00c0c76550 CI += zsh-5.8
Fixes #740.
2020-05-26 17:52:17 +00:00
Matthew Martin
870bccf8ff main: Add tests for arithmetic expansion 2020-05-23 20:29:09 -05:00
Matthew Martin
a238647df9 main: Add arithmetic substitution highlighting
Closes #607 #649 #704
2020-05-23 20:29:00 -05:00
Daniel Shahaf
f8b1470314 changelog.md: Restore vertical whitespace before section headers. 2020-05-22 04:55:17 +00:00
Daniel Shahaf
ade4b28d2d 'main': Fix issue #677, concerning multiline aliases.
The fix is to exempt such aliases from the empty commands sanity check.
2020-05-22 04:54:10 +00:00
Daniel Shahaf
8211a95421 changelog: Update through HEAD. 2020-05-22 04:44:49 +00:00
Daniel Shahaf
d4df626c03 'main': Optimize the unquoted arguments characterwise walker
Fixes #730.

% repeat 3 { zsh -f tests/test-zprof.zsh main | tee … | grep -w _zsh_highlight | head -n1 }
19)    1       26787.11 26787.11  100.00%      5.33     5.33    0.02%  _zsh_highlight
19)    1       26900.64 26900.64  100.00%      5.45     5.45    0.02%  _zsh_highlight
19)    1       26915.76 26915.76  100.00%      5.47     5.47    0.02%  _zsh_highlight

Merge remote-tracking branch 'danielsh/perf-argument-1-v2'

* danielsh/perf-argument-1-v2:
  'main': Further optimize argument parsing.
  'main': Optimize a hot path.
  tests: Add a performance testing script, for measuring the performance of the 'main' highlighter on a large file.
2020-05-22 04:43:04 +00:00
Daniel Shahaf
8f5d74d219 'main': Further optimize argument parsing.
% repeat 3 { zsh -f tests/test-zprof.zsh main | tee … | grep -w _zsh_highlight | head -n1 }
18)    1       26895.86 26895.86  100.00%      6.35     6.35    0.02%  _zsh_highlight
19)    1       27399.11 27399.11  100.00%      5.52     5.52    0.02%  _zsh_highlight
19)    1       27027.58 27027.58  100.00%      5.66     5.66    0.02%  _zsh_highlight

----

This commit has been rebased.  The above statistics were measured after
the rebase.  The below statistics had been measured before the rebase.

num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)    3       25689.17  8563.06   98.15%  18422.01  6140.67   70.38%  _zsh_highlight_main_highlighter_highlight_list
 2) 32390        5706.13     0.18   21.80%   2315.68     0.07    8.85%  _zsh_highlight_main_highlighter_highlight_argument
19)    1       26173.33 26173.33  100.00%      5.27     5.27    0.02%  _zsh_highlight

Interestingly, if I make the change in this diff to
_zsh_highlight_main_highlighter_highlight_double_quote —

>     diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh
>     index da6ab2b..bb17618 100644
>     --- a/highlighters/main/main-highlighter.zsh
>     +++ b/highlighters/main/main-highlighter.zsh
>     @@ -1462,10 +1462,13 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
>        local i j k ret style
>        reply=()
>
>     -  for (( i = $1 + 1 ; i <= $#arg ; i += 1 )) ; do
>     +  (( i = $1 ))
>     +  while (( ++i <= $#arg )); do
>     +    i=${arg[(ib.i.)[\"\`\$\\\\${histchars[1]}]]}
>          (( j = i + start_pos - 1 ))
>          (( k = j + 1 ))
>          case "$arg[$i]" in
>     +      ("")  break;;
>            ('"') break;;
>            ('`') saved_reply=($reply)
>                  _zsh_highlight_main_highlighter_highlight_backtick $i

— it actually makes things measurably slower (!), even on input that has
a large number of pasted double-quoted strings: on «BUFFER=": ${(r.8*1500..foo"bar".):-}"»
the slowdown is (1123.24ms / 1091.06ms = 1.0295).  Therefore, I won't be
committing that change.
2020-05-22 04:36:59 +00:00
Daniel Shahaf
700c0e18fe 'main': Optimize a hot path.
% git co HEAD^ && repeat 3 { zsh -f tests/test-zprof.zsh main | tee … | grep -w _zsh_highlight | head -n1 }
HEAD is now at 64e3651 'main': Optimize a hot path.
19)    1       28765.13 28765.13  100.00%      5.57     5.57    0.02%  _zsh_highlight
19)    1       28566.46 28566.46  100.00%      5.91     5.91    0.02%  _zsh_highlight
19)    1       28248.12 28248.12  100.00%      5.57     5.57    0.02%  _zsh_highlight

----

This commit has been rebased.  The above statistics were measured after
the rebase.  The below statistics had been measured before the rebase.

Before this patch:

    num  calls                time                       self            name
    -----------------------------------------------------------------------------------
     1)    3       33410.81 11136.94   98.51%  19277.07  6425.69   56.84%  _zsh_highlight_main_highlighter_highlight_list
    19)    1       33916.21 33916.21  100.00%      5.27     5.27    0.02%  _zsh_highlight

With this patch:

    num  calls                time                       self            name
    -----------------------------------------------------------------------------------
     1)    3       27167.49  9055.83   98.17%  18754.77  6251.59   67.77%  _zsh_highlight_main_highlighter_highlight_list
    19)    1       27674.40 27674.40  100.00%      5.39     5.39    0.02%  _zsh_highlight

And if test-zprof.zsh is changed to not set interactivecomments:

    num  calls                time                       self            name
    -----------------------------------------------------------------------------------
     1) 13360       36029.12     2.70   83.56%  30304.23     2.27   70.28%  _zsh_highlight_main_highlighter_highlight_argument
    21)    1       43117.76 43117.76  100.00%      4.52     4.52    0.01%  _zsh_highlight

    num  calls                time                       self            name
    -----------------------------------------------------------------------------------
     1) 13360       14782.89     1.11   68.12%   9163.42     0.69   42.23%  _zsh_highlight_main_highlighter_highlight_argument
    21)    1       21699.93 21699.93  100.00%      4.17     4.17    0.02%  _zsh_highlight
2020-05-22 04:32:39 +00:00
Daniel Shahaf
a50647e77b tests: Add a performance testing script, for measuring the performance of the 'main' highlighter on a large file.
% git co HEAD^ && repeat 3 { zsh -f tests/test-zprof.zsh main | tee … | grep -w _zsh_highlight | head -n1 }
HEAD is now at f1948df tests: Add a performance testing script, for measuring the performance of the 'main' highlighter on a large file.
19)    1       34378.97 34378.97  100.00%      5.43     5.43    0.02%  _zsh_highlight
19)    1       34058.34 34058.34  100.00%      5.50     5.50    0.02%  _zsh_highlight
19)    1       34364.80 34364.80  100.00%      5.36     5.36    0.02%  _zsh_highlight
2020-05-22 04:31:48 +00:00
Daniel Shahaf
b253a8b86a changelog: Update through HEAD.
The great-grandparent commit, "a3ae74 'main': Fix the last commit's bug
concerning parameter elision not happening in redirects in command
position.", is not added because it's not a change with respect
to 0.7.1.
2020-05-22 03:30:49 +00:00
Daniel Shahaf
4dd4797ae0 test harness: Print the expected-v.-actual on every failure, not just upon cardinality failures.
I was looking into something and wanted to see how a the second word in the
array was highlighted, even though the failure was on the third word.
2020-05-22 03:27:48 +00:00
Daniel Shahaf
5171ec524f Document ZSH_HIGHLIGHT_MAXLENGTH.
Fixes #698.
2020-05-22 02:23:18 +00:00
Daniel Shahaf
ea3ae74164 'main': Fix the last commit's bug concerning parameter elision not happening in redirects in command position. 2020-05-13 12:51:52 +00:00
Daniel Shahaf
41b8a74692 'main': Add a test for parameter elision not happening in redirects in command position.
Will be fixed in the next commit.
2020-05-13 12:51:40 +00:00
Daniel Shahaf
3a4b212c7d 'main': Fix regression in zsh 5.3.1 and older: all precmd hooks later than z-sy-h would be aborted.
In those versions of zsh, «[[ -o nosuchoption ]]» is regarded as
a syntax error.  In newer zsh versions, it merely returns non-zero
(specifically, it returns 3, unlike «[[ -o unsetoption ]]» which
returns 1).

Fixes #732.
Fixes #733.
2020-05-06 20:27:55 +00:00
Daniel Shahaf
0582ea1910 changelog += WARN_NESTED_VAR fixes (#727, #731) 2020-05-05 17:59:51 +00:00
Daniel Shahaf
e65ebf0466 'main': Fix a regression caused by the great-grandparent commit's WARN_NESTED_VAR fix.
An error message was emitted on versions of zsh that don't have the
WARN_NESTED_VAR option.

Fixes #731.
2020-05-05 14:31:42 +00:00
Daniel Shahaf
06710f3780 'main': Don't run _zsh_highlight_main__type on every non-command word.
Fixes #728, the performance regression from 0.7.1.
2020-05-04 18:35:15 +00:00
Daniel Shahaf
343ec1061f 'make perf': Show only a cumulative datum per highligher, rather than per test file.
The overall per-highlighter duration should be less prone to random
noise than the multitude of per-test-file figures.
2020-05-04 17:48:47 +00:00
Daniel Shahaf
b08d508cd8 driver: Fix a bug that prevented subsequent, third-party zle-line-pre-redraw hooks from running.
Without this patch, `_zsh_highlight` was invoked by add-zle-hook-widget
with `$?` being non-zero (see add-zle-hook-widget:48-52).  Since
`_zsh_highlight` preserves `$?` from its caller's point of view,
add-zle-hook-widget saw a non-zero exit code from `_zsh_highlight` and
did not run any the remaining zle-line-pre-redraw hooks.

See https://github.com/zsh-users/zsh-syntax-highlighting/issues/579#issuecomment-623576907.
2020-05-04 16:45:21 +00:00
Daniel Shahaf
16d818a21f 'main': Don't trip WARN_NESTED_VAR.
Fixes #727.
2020-05-04 13:27:33 +00:00
Daniel Shahaf
f1b9fbbaf0 'main': Follow-up to previous: Document the version number, and deduplicate some option letters. 2020-04-20 11:11:29 +00:00
Daniel Shahaf
8d32609a7b 'main': precommands += strace 2020-04-20 11:09:24 +00:00
Daniel Shahaf
f5d1be7ec2 editorconfig: Fix Makefile settings 2020-04-12 02:59:39 +00:00
Dimitris Apostolou
415e762ab2
Fix typo 2020-04-08 21:04:48 +03:00
Daniel Shahaf
ccb1da4ae8 Bump copyright years. 2020-04-03 02:03:18 +00:00
Daniel Shahaf
96eb2e31a1 driver: Fix "_zsh_highlight:3: read-only variable: ret" warnings when POSIX_BUILTINS is set.
Fixes #719.

Cf. #688.
2020-04-03 01:19:38 +00:00
Daniel Shahaf
291634ecfe tests: Add a test for the infinite loop fixed by each of the last two commits.
Accidentally lost during a rebase.
2020-04-03 01:04:31 +00:00
Daniel Shahaf
96e6cbe22f 'main': Fix expansion of positional parameters in _zsh_highlight_main_highlighter__try_expand_parameter.
As described in the last commit's log message, ${parameter_name_pattern]
explicitly matches positional parameters but ${parameters[$MATCH]}
expands to nothing in that case (when, e.g., [[ $MATCH == '1' ]]; note
this is equality of strings, not integers).

As a side effect, this removes the dependency on the zsh/parameter
module for expanding parameters.
2020-04-02 23:52:05 +00:00
Daniel Shahaf
2a30d4fb5a 'main': Fix an infinite loop.
On the test case, the behaviour was as follows:

+highlighters/main/main-highlighter.zsh:733> _zsh_highlight_main_highlighter__try_expand_parameter '$1'
+highlighters/main/main-highlighter.zsh:432> local arg='$1'
+highlighters/main/main-highlighter.zsh:433> unset reply
+highlighters/main/main-highlighter.zsh:439> local -a match mbegin mend
+highlighters/main/main-highlighter.zsh:440> local MATCH
+highlighters/main/main-highlighter.zsh:440> integer MBEGIN MEND
+highlighters/main/main-highlighter.zsh:441> local parameter_name
+highlighters/main/main-highlighter.zsh:442> local -a words
+highlighters/main/main-highlighter.zsh:443> [[ '$' != \$ ]]
+highlighters/main/main-highlighter.zsh:446> [[ 1 == { ]]
+highlighters/main/main-highlighter.zsh:449> parameter_name=1
+highlighters/main/main-highlighter.zsh:451> [[ none == none ]]
+highlighters/main/main-highlighter.zsh:451> zmodload -e zsh/parameter
+highlighters/main/main-highlighter.zsh:452> [[ ${parameter_name} -regex-match ^${~parameter_name_pattern}$ ]]
+highlighters/main/main-highlighter.zsh:453> [[ '' != *special* ]]
+highlighters/main/main-highlighter.zsh:456> case array-special (*array*|*assoc*)
+highlighters/main/main-highlighter.zsh:458> words=( '$1' )
+highlighters/main/main-highlighter.zsh:469> reply=( '$1' )

There are two problems here:

- In terms of _zsh_highlight_main_highlighter__try_expand_parameter's
  pre- and postconditions, the expansion of the word «$1» (line 733)
  included that same word (line 469).

  That happened because word-to-be-expanded is passed to
  _zsh_highlight_main_highlighter__try_expand_parameter as its first
  positional parameter, and in this case the word happened to be «$1».

- Furthermore, the exclusion of special parameters (line 453) false
  negatived.  That happened because $parameter_name_pattern explicitly
  allows positional parameters, but ${parameters[(e)1]} expands to
  nothing.  This will be fixed in the next commit.

Not a regression from 0.7.1.
2020-04-02 23:44:11 +00:00
Daniel Shahaf
90fec4d658 'main': precommands += ionice(1) (from util-linux) 2020-04-01 06:38:41 +00:00
Daniel Shahaf
f563780236 driver: Simplify initialization of $zsyh_user_options in the fallback codepath. 2020-03-29 20:54:28 +00:00
Daniel Shahaf
b8c93afd34 driver: Make sure we don't change the return value in a called function. 2020-03-29 20:45:46 +00:00
Daniel Shahaf
2aca4e2c02 'main': Make logic more robust. No functional change.
Before this commit, if the value didn't begin with a dollar sign,
_zsh_highlight_main_highlighter__try_expand_parameter() would return 1
by accident.¹  Tweak the input validation to make this behaviour
explicit.  No functional change.

¹ Specifically, it would return 1 because ${parameter_name}'s value
would be the empty string and ${parameter_name_pattern} wouldn't match
that.
2020-03-28 03:57:13 +00:00
Daniel Shahaf
7678a8a227 'main': Break out an anonymous function into a named function.
This is in order to allow it to be reused.

No functional change.
2020-03-27 01:29:11 +00:00
Daniel Shahaf
5d139fcd94 Fix typos in comments. 2020-03-27 01:28:11 +00:00
Matthew Martin
d1802e388e main: Add test for issue #713 2020-03-22 15:01:53 -05:00
Daniel Shahaf
aecfd61bbd 'main': Support the 'env' precommand. 2020-03-21 01:45:34 +00:00
Daniel Shahaf
2904e0f986 test harness: Fix the pretty-printer's padding implementation.
The new implementation is less efficient but definitely correct.
2020-03-20 00:03:01 +00:00
Daniel Shahaf
d5d2f22013 Revert "test harness: Rewrite the columnar pretty-printer without external tools." and "travis: Remove bsdmainutils since column(1) has been removed, three commits ago."
This reverts commits ea7c165b59 and
3d81c83132.

When "have 6 expectations and 4 region_highlight entries", the pure-zsh
implementation printed them as follows:

    not ok 7 - cardinality check - have 6 expectations and 4 region_highlight entries: «expected_region_highlight=( $'1 1 builtin' $'3 6 comment' $'8 13 comment' $'15 15 default' $'16 21 comment' $'22 22 default' )»
    «region_highlight=( $'0 1 builtin' $'2 6 comment' $'7 13 comment' $'14 22 default' )»
    # expected_region_highlight  '22 22 default'
    # '1 1 builtin'              region_highlight
    # '3 6 comment'              '0 1 builtin'
    # '8 13 comment'             '2 6 comment'
    # '15 15 default'            '7 13 comment'
    # '16 21 comment'            '14 22 default'

Whereas the column(1)-based implementation prints them as follows:

    not ok 7 - cardinality check - have 6 expectations and 4 region_highlight entries: «expected_region_highlight=( $'1 1 builtin' $'3 6 comment' $'8 13 comment' $'15 15 default' $'16 21 comment' $'22 22 default' )» «region_highlight=( $'0 1 builtin' $'2 6 comment' $'7 13 comment' $'14 22 default' )»
    # expected_region_highlight  region_highlight
    # '1 1 builtin'              '0 1 builtin'
    # '3 6 comment'              '2 6 comment'
    # '8 13 comment'             '7 13 comment'
    # '15 15 default'            '14 22 default'
    # '16 21 comment'
    # '22 22 default'

Ultimately, this difference is down to the pure-zsh implementation
getting the arguments as a single list, whereas paste(1) gets two
separate lists.
2020-03-20 00:03:01 +00:00
Daniel Shahaf
8eaa41431d changelog: Update through HEAD. 2020-03-19 21:25:49 +00:00
Daniel Shahaf
e4f24f8901
Merge pull request #669 from danielshahaf/cdpath-and-nonexecutable-in-command-position-v1
Command position: non-executable files, non-cdable directories, CDPATH false positives
2020-03-19 21:22:52 +00:00
Daniel Shahaf
1000da306a 'main': Correctly highlight '&&' and '||' inside '[[ … ]]' conditions. 2020-03-19 20:16:43 +00:00
Daniel Shahaf
b44964c545 'main': Highlight reserved words following assignments as errors.
Fixes #461.
2020-03-19 19:48:44 +00:00
Daniel Shahaf
f54d829f03 tests: Add tests for issue #461. 2020-03-19 19:43:12 +00:00
Daniel Shahaf
9e9885253a test harness: Output the time information to the same place the test name was printed to. 2020-03-19 19:17:41 +00:00
Daniel Shahaf
3e7745ef30 test harness: Stringify values in a more readable manner.
(q-) passes through newlines and NUL bytes verbatim.  Using (qqqq) ensures the
escaped string will be on a single line (as required by the TAP format) and be
readable even if it contains control characters.
2020-03-19 19:15:21 +00:00
Daniel Shahaf
b0af27f25f tests: Add a unit test for a path specified with mixed quoting.
Fixes #475.
2020-03-19 06:49:40 +00:00
Daniel Shahaf
bd9094cc61 tests: Add a test for issue #498, which has already been fixed. 2020-03-19 06:44:12 +00:00
Daniel Shahaf
c7229a000a tests: Test that global qualifiers and command substitutions aren't evaluated.
Fixes #504.
2020-03-19 06:41:38 +00:00
Daniel Shahaf
f2726d0464 'main': Don't consider path_prefix in alias expansions. 2020-03-19 06:06:30 +00:00
Daniel Shahaf
8184266338 'main': Add a test for aliases to AUTO_CD directories. 2020-03-19 06:06:30 +00:00
Daniel Shahaf
83ac855ceb 'main': Let AUTO_CD directories be highlighted with their own style. 2020-03-19 06:06:30 +00:00
Daniel Shahaf
3f930fb0c1 'main': Add an auxiliary variable for readability. 2020-03-19 06:06:30 +00:00
Daniel Shahaf
5545fb9ab2 'main': In command position, do not highlight directories (unless AUTO_CD is set) and non-executable files.
Fixes #202.

Test expectations are updated.  For example, BUFFER='/bin' is now
highlighted as path_prefix because it's a prefix of '/bin/sh' which
would be valid.  However, BUFFER='/bin;' is now properly highlighted
as an error (unless AUTO_CD is set).
2020-03-19 06:06:30 +00:00
Daniel Shahaf
a6eb966d96 'main': Extend tests to capture the current behaviour.
The next commits will change this behaviour.
2020-03-19 06:05:23 +00:00
Daniel Shahaf
c67372e96c 'main': Add an XFail test for issue #202. 2020-03-19 06:05:23 +00:00
Daniel Shahaf
29ca0bc6c8 'main': Highlight errors from the EQUALS option.
Fixes #430.
2020-03-19 05:59:04 +00:00
Daniel Shahaf
08839bbd87 'main': Let the type determination ignore global aliases when it ignores regular ones. 2020-03-19 05:28:17 +00:00
Daniel Shahaf
e2dddb91c6 'main': Add a regression test for parameters that expand to global aliases.
Will be fixed in the next commit.
2020-03-19 05:27:31 +00:00
Daniel Shahaf
cfef4f3ae0 'main': Enable the zsh/parameter codepath of global aliases highlighting. 2020-03-19 05:13:46 +00:00
Daniel Shahaf
48dd47931a changelog: Update through HEAD. 2020-03-19 05:13:17 +00:00
Daniel Shahaf
3d81c83132 travis: Remove bsdmainutils since column(1) has been removed, three commits ago. 2020-03-19 05:11:21 +00:00
Daniel Shahaf
3c5f63d959 'main': Highlight global aliases 2020-03-19 05:05:37 +00:00
Daniel Shahaf
5a44d9f32a tests: Record current behaviour on global aliases. 2020-03-19 05:04:15 +00:00
Daniel Shahaf
ea7c165b59 test harness: Rewrite the columnar pretty-printer without external tools. 2020-03-19 05:01:54 +00:00
Daniel Shahaf
90a92b2bb8 test harness: Fix an issue with the pretty-printed $expected_region_highlight/$region_highlight diffing.
If the right column was longer, the excess entries were printed on the left column.
2020-03-19 05:01:54 +00:00
Daniel Shahaf
fdf23e06c7 'main': Support the "close file descriptor" and "coproc" redirection syntaxes
Part of issue #645.
2020-03-19 03:15:37 +00:00
Daniel Shahaf
10171731f3 tests: Add a test for the "close file descriptor" and "coproc" redirection syntaxes
Part of issue #645.
2020-03-19 03:14:15 +00:00
Daniel Shahaf
dfc41123d7 tests: Fix the test added in the last commit. 2020-03-19 02:30:58 +00:00
Daniel Shahaf
d6defe715a tests: Add a test for issue #705, concerning continuation lines. 2020-03-19 01:39:33 +00:00
Daniel Shahaf
3ff5bec82e test harness: Let tests fail early by exiting non-zero or by setting a flag.
Fixes #609.
2020-03-19 00:37:21 +00:00
Daniel Shahaf
c4bb260a30 test harness: Print the test name when $skip_test is set. 2020-03-19 00:16:09 +00:00
Daniel Shahaf
9bdeb4aa4a test harness: Remove a bogus check.
We already declare $expected_region_highlight in run_test_internal().
Therefore, it will always be declared.
2020-03-19 00:03:24 +00:00
Daniel Shahaf
63852df983 test harness: Fix $skip_test support, broken yesterday.
It was broken by commit e6eea1f9b7,
"test harness: Don't leak options from test files to the test harness.".
2020-03-19 00:00:51 +00:00
Daniel Shahaf
66021cf0f7 travis: Install bsdmainutils to provide column(1).
See the last commit,
bdb4e8b70e test harness: When the cardinality check fails, pretty-print \$expected_region_highlight and \$region_highlight.
2020-03-17 17:17:51 +00:00
Daniel Shahaf
0f627fdf60 Merge remote-tracking branch 'danielsh/whitespace-historical'
* danielsh/whitespace-historical:
  Fix historical instances of one-space indentation.
2020-03-17 17:08:06 +00:00
Daniel Shahaf
bdb4e8b70e test harness: When the cardinality check fails, pretty-print \$expected_region_highlight and \$region_highlight. 2020-03-17 17:06:32 +00:00
Daniel Shahaf
e6eea1f9b7 test harness: Don't leak options from test files to the test harness.
Fixes an issue whereby the '# TODO "issue #687"' directive in the output of
opt-shwordsplit1.zsh was truncated, because the test itself had set the
SH_WORD_SPLIT option and that affected the evaluation of
«${(z)expected_region_highlight[i]}» in the test harness.

Furthermore, this patch also independently fixes the error under
zsh-5.0.8 and earlier that was fixed by the previous commit.
2020-03-17 16:48:57 +00:00
Daniel Shahaf
99389327ae test harness: Fix test failures under zsh 5.0.8 and older.
The output of test-data/opt-shwordsplit1.zsh on zsh 5.7 is:
.
    1..2
    ## opt-shwordsplit1
    # BUFFER=vim
    not ok 1 - [1,7] «$EDITOR» - expected (1 7 "function"), observed (1 7 "unknown-token"). # TODO "issue
    ok 2 - cardinality check # SKIP cardinality check disabled whilst regular test points are expected to fail

On zsh 5.0.8, tap_escape() choked when called on the arguments argv=('[1,7]'
'«vim»').  This patch fixes that.

As you may have noticed, under zsh 5.7 the diagnostic message of test point 1
is truncated.  That'll be fixed in the next commit.
2020-03-17 16:22:56 +00:00
Daniel Shahaf
e165f18c75 'main': Fix a bug manifesting under zsh 5.2 and older.
The escaped caret was taken for a negated character class.  This caused test-data/arith1.zsh
to XPass: the arithmetic expansion was consumed by the 'while' loop.
2020-03-17 16:13:32 +00:00
Daniel Shahaf
d237a60c9b 'main': Don't highlight arithmetic expansions as command substitutions.
This is not perfect: we don't try to detect cases such as «$((ls); (ls))»,
which look like arithmetic expansions but are in fact command substitutions.

Fixes part of #607.

Introduces #704.
2020-03-17 15:05:32 +00:00
Daniel Shahaf
2e65bb6d7d tests: Add a test documenting the current state, prior to introducing #704. 2020-03-17 15:05:32 +00:00
Daniel Shahaf
61c1cfe99f test harness: Change cardinality check semantics
The cardinality check shall —

- if the test sets \$expected_mismatch, be XFail;
- elif any test points is XFail, be skipped;
- else, be expected to pass.

To test this, change «6 * 9» to «6 + 9» in test-data/arith1.zsh that
will be added in the after-next (grandchild) commit.
2020-03-17 15:05:22 +00:00
Daniel Shahaf
ea2f1060f6 test harness: No-op change to minimize the next diff. 2020-03-17 15:05:22 +00:00
Daniel Shahaf
e79ce6afd0 'main': Document additional meanings of the 'S' $braces_stack flag. 2020-03-17 14:12:00 +00:00
Daniel Shahaf
fb69f4ca81 'main': When the redirection operator '>&' or '<&' is followed by a positive integer, do not consider that as a filename; it's always a file descriptor.
Fixes #694.
2020-03-17 04:00:43 +00:00
Daniel Shahaf
1024ae8177 'main': Add $last_arg for "lookbehind". 2020-03-17 03:58:15 +00:00
Daniel Shahaf
5720d87052 noop: Clarify comment. 2020-03-17 03:48:40 +00:00
Daniel Shahaf
2339ee33b9 'main': Honour the MULTIOS option when applying the 'globbing' style.
Fixes #583.
2020-03-17 03:32:58 +00:00
Daniel Shahaf
61945185ff 'main': Document what $in_redirection is currently used for. 2020-03-17 03:18:27 +00:00
Daniel Shahaf
936bc251a8 'main': The optimized cmdsubst input syntax doesn't glob.
Fixes #582.
2020-03-17 03:11:52 +00:00
Daniel Shahaf
c699ce9a26 changelog: Fix markup. 2020-03-17 03:10:08 +00:00
Daniel Shahaf
6e1a221699 tests: Add a test for issue #571. 2020-03-17 02:58:16 +00:00
Daniel Shahaf
9ceb7c6e7c changelog.md (0.7.0): Fix typo 2020-03-17 01:51:32 +00:00
Daniel Shahaf
b454b596ed Fix historical instances of one-space indentation.
No functional change.
2020-03-17 00:48:16 +00:00
Daniel Shahaf
e815d4579b tests: Add a test for a bug fixed in 2d0dddf58b "'main': Don't dequote the word in command position before analyzing it.".
Fixes #630.
2020-03-16 22:27:04 +00:00
Daniel Shahaf
3174e375f4 'main': Fix highlighting of null execs.
Fixes #676.
2020-03-16 21:50:04 +00:00
Daniel Shahaf
f56e3fad23 'main': Optimize the path_prefix check.
Computing ${#array} is O(N), whereas checking 0 is O(1).
2020-03-16 20:45:56 +00:00
Daniel Shahaf
62e2d05f91 changelog: Update through HEAD. 2020-03-16 19:34:48 +00:00
Daniel Shahaf
2cc2583f8f Merge the first three commits of PR #669
* commit 'b1f36d9c5f45b879fbd2f64195167a60d9f3cb9e':
  'main': Add a comment.
  'main': Fix the $CDPATH from the previous commit.
  'main': Add a test for a $CDPATH bug.
2020-03-16 19:32:59 +00:00
Daniel Shahaf
e15781c900 changelog: Update through HEAD. 2020-03-16 19:26:28 +00:00
Daniel Shahaf
20d250d618 'main': Support the non-precommand flags of sudo(8) and ssh-agent(1).
Uses the infrastructure added in the previous commit.

Fixes #678.
2020-03-16 19:22:54 +00:00
Daniel Shahaf
c73153c6e8 'main': Add infrastructure for precommand options that are not to be followed by a command word (issue #678). 2020-03-16 19:20:31 +00:00
Daniel Shahaf
63bcd85dfa 'main': Don't use «foo && bar || baz» where a trenary is more appropriate.
This prevents the baz pattern match from being attempted whenever the
bar pattern match was tried and failed.
2020-03-16 19:14:51 +00:00
Daniel Shahaf
4bbd2a3bc6 'main': Prepare to add additional fields to $precommand_options values.
No functional change.
2020-03-16 19:07:57 +00:00
Daniel Shahaf
241d3a92e8 tests: Fix an XFail test expectation.
Before this commit, the test was unable to XPass, since there is no
highlighting style called "normal".
2020-03-16 19:04:12 +00:00
Daniel Shahaf
6243c99f41 tests: Fixup last commit. 2020-03-16 18:57:28 +00:00
Daniel Shahaf
8f7e9b2af4 tests: Add a test for uninstalled precommands. 2020-03-15 19:55:42 +00:00
Daniel Shahaf
f63f07417d Merge remote-tracking branch 'danielsh/tests-skip-cardinality-v1'
* danielsh/tests-skip-cardinality-v1:
  tests: Minor documentation readability tweak
  Add a test for issue #641.5, using the infrastructure added in the previous commits.
  tests: Skip cardinality tests whenever any test point is expected to fail.
  tests: Make $expected_mismatch skip the cardinality check, rather than consider it an expected failure.
  tests: Include the name of the 'cardinality check' test point in the output
2020-03-15 18:38:26 +00:00
Daniel Shahaf
2331072c06 changelog: Update through HEAD. 2020-03-15 18:32:44 +00:00
Daniel Shahaf
9e036e0b0c 'main': Document the second meaning of the 'comment' style. 2020-03-15 18:30:53 +00:00
Daniel Shahaf
74c7ffc9b5 'main': Factor out common logic to after the case/esac. 2020-03-15 18:30:53 +00:00
Daniel Shahaf
8feb06a022 'main': Support parameter elision in command position. 2020-03-15 18:25:13 +00:00
Daniel Shahaf
fdf682a2f9 'main': Expand comment. 2020-03-15 18:14:39 +00:00
Daniel Shahaf
f564d11a41 make test: Re-enable syntax highlighting of TAP output in interactive runs
Fixes #692.
2020-03-15 18:10:18 +00:00
Daniel Shahaf
8072651b6c editorconfig += Makefile 2020-03-15 18:10:03 +00:00
Daniel Shahaf
9931990b92 tests: Fix the test for alias loops.
Before this commit, the command word was highlighted as "unknown-token"
not because alias loops are invalid, as a comment incorrectly claimed,
but because the command word «a» resolved to a «b» that was ineligible
for being expanded as an alias, and there was no function/builtin/etc.
called "b".

Add a function "b" to demonstrate that alias loops are valid.  I've also
filed issue #695 about the overloading of "unknown-token".
2020-03-15 17:22:35 +00:00
Daniel Shahaf
525ba90932 tests: Add an XFail test for issue #694. 2020-03-15 16:06:35 +00:00
Daniel Shahaf
9134cdf8d6 'main': Allow newlines in command position.
Fixes #501.

Fixes #616 (the original form; not the form in
test-data/alias-comment1.zsh which is now considered o be #677 (see
previous commit for details)).

Fixes a latent bug in test-data/always2.zsh.

No user-visible effect, and therefore, no changelog entry.
2020-03-15 15:38:07 +00:00
Daniel Shahaf
e94dc89606 tests: Distinguish issues #616 and #677.
See https://github.com/zsh-users/zsh-syntax-highlighting/issues/677#issuecomment-599225740 for details.

(In particular, there's already another test that calls itself #616.)
2020-03-15 15:35:29 +00:00
Daniel Shahaf
f996d83975 tests: Add cross-references. 2020-03-15 15:24:06 +00:00
Daniel Shahaf
54e1828d5c 'main': Clarify documentation of the :sudo_opt: and :sudo_arg: states. 2020-03-15 14:56:43 +00:00
Daniel Shahaf
c5878ae632 changelog: Update through HEAD. 2020-03-15 14:37:04 +00:00
Daniel Shahaf
498cc7641f tests: Extend and document the after-a-parse-error aspects of the issue #651 test. 2020-03-15 14:34:25 +00:00
Daniel Shahaf
81267ca313 'main': Highlight pipes inside array assignments as errors
Fixes #651.
2020-03-15 14:27:15 +00:00
Daniel Shahaf
bfd44f5c3f noop: Add comments. 2020-03-15 14:22:05 +00:00
Daniel Shahaf
3ca93f864f 'main': Highlight literal semicolons in array assignments as errors.
Fixes the test added in the penultimate (grandparent) commit.
2020-03-15 14:19:38 +00:00
Daniel Shahaf
a4525a0826 'main': Add infrastructure for treating literal newlines differently to semicolons.
Used by the next commit.
2020-03-15 14:19:38 +00:00
Daniel Shahaf
e58e45273f tests: Add some tests for unusual or invalid elements in array assignments:
- pipes (issue #651)
- semicolons
- literal newlines
  (also discussed on #651)
2020-03-15 14:19:38 +00:00
Daniel Shahaf
37b6f5052f test harness: Update tests/edit-failed-tests for harness output changes in commit 2b3638a211, "test harness: Tweak quiet-test output". 2020-03-15 13:33:09 +00:00
Daniel Shahaf
a3c1757e47 changelog: Update through HEAD. 2020-03-13 23:13:01 +00:00
Austin Traver
b00be5f741 driver: Be resilient to KSH_ARRAYS being set in the calling scope
The «emulate» call isn't sufficient, since these lines are parsed before
it takes effect.

Fixes #689 (née #622).

See also #688 for preventing these gymnastics from being needed in the
first place.

See also https://github.com/junegunn/fzf/pull/1924 for an inter-plugin
interaction that this probably fixes.
2020-03-13 16:18:07 +00:00
Matthew Martin
b85e313bc9 main: Declare variable local to fix WARN_CREATE_GLOBAL error 2020-03-12 20:51:19 -05:00
Matthew Martin
41d90cb5ed make test: Run tests under env -i
This makes the tests more reproducable. In particular it avoids hiding
a WARN_CREATE_GLOBAL error when the dev happens to have defined that
variable in the environment (cf. next commit).
2020-03-12 20:48:46 -05:00
Daniel Shahaf
34df84a7dd 'main': Add a test for issue #687, concerning the SH_WORD_SPLIT option. 2020-03-11 16:52:08 +00:00
Daniel Shahaf
1a752da1c2 Highlight redirections by default, and add that to the examples in README.
Fixes #646.
2020-02-28 22:49:02 +00:00
Daniel Shahaf
8e3578240c tests harness docs: Add paragraph breaks. 2020-02-28 22:36:57 +00:00
Daniel Shahaf
edfc7dfd9b 'main': Fix issue #577. 2020-02-28 22:36:57 +00:00
Daniel Shahaf
9880276756 'main': Fix the currently-failing test for issue #577.
It is fixed in the next commit.
2020-02-28 22:35:56 +00:00
Daniel Shahaf
027f522300 test harness: Honour $expected_mismatch when there are more expected than observed highlights.
Required for the next commit.
2020-02-28 22:31:43 +00:00
Daniel Shahaf
619fcad067 Post-release version number bump. 2020-02-28 21:34:58 +00:00
Daniel Shahaf
932e29a0c7 Tag version 0.7.1. 2020-02-28 21:34:10 +00:00
Daniel Shahaf
ec04a20681 release.md: Update with the step that was missed in 0.7.0. 2020-02-28 21:33:51 +00:00
Daniel Shahaf
cb8d68d00a Update changelog for the 0.7.1 release. 2020-02-28 21:32:42 +00:00
Daniel Shahaf
04dd78cb00 Update changelog for the 0.7.0 release. (Yes, this should have been committed earlier today.) 2020-02-28 21:29:59 +00:00
Daniel Shahaf
4eb8a19133 Post-release version number bump. 2020-02-28 15:38:43 +00:00
Daniel Shahaf
36a3c0f82c Tag version 0.7.0. 2020-02-28 15:36:43 +00:00
Daniel Shahaf
d65f4f8a35 release.md: Add details about a step. 2020-02-28 15:36:25 +00:00
Daniel Shahaf
e07c901dfd tests: Fix the last added test to pass when sudo(8) isn't installed. 2020-02-28 15:22:43 +00:00
Daniel Shahaf
3cea1434ae Bump copyright years. 2020-02-25 17:34:35 +00:00
Daniel Shahaf
73c89c69a2 tests: Add a test for partial elisions of parameter expansions in command position
See 1a55dc8fc2 (commitcomment-37476021)
2020-02-25 17:22:55 +00:00
Matthew Martin
7fd44bc429 tests: Fix previous 2020-02-25 07:37:09 -06:00
Matthew Martin
ab88dfad27 tests: Add main test for alias of a parameter like string 2020-02-25 07:21:40 -06:00
Daniel Shahaf
2b3638a211 test harness: Tweak quiet-test output
- Print the test name and data after the plan line

- Split on the plan line rather than on comments

  + That makes tap-filter more suitable to filter TAP output generated by other
    TAP producers.

  + However, the filtered output deletes the plan line and adds a blank line in
    its stead.  This suits our use-case of interactive test runs.
2020-02-22 15:12:24 +00:00
Daniel Shahaf
3414c7c0d2 test harness: Include $PREBUFFER and $BUFFER in the output.
For human readers' benefit.
2020-02-22 15:12:24 +00:00
Daniel Shahaf
4a043b4d15 noop: Whitespace changes only.
./.editorconfig is already set correctly.
2020-02-22 15:12:24 +00:00
Daniel Shahaf
dc70e89bfd tests: Support non-arrays in typeset_p(). 2020-02-22 15:12:24 +00:00
Daniel Shahaf
f729726300 'main': Do not look for metacharacters in parameter expansions.
Fixes the bug the previous commit added a test for.
2020-02-22 15:12:24 +00:00
Daniel Shahaf
f490b7cb95 'main': Add two tests for metacharacters in parameter expansions.
Suggested-by: @QBobWatson
(in https://github.com/zsh-users/zsh-syntax-highlighting/pull/682#issuecomment-588361771)
2020-02-22 15:12:24 +00:00
Daniel Shahaf
2f4f81cab7 'main': Parameter expansions may not contain assignments.
In «a="b=c"; $a», the '=' sign in the expansion of $a is not active.
Therefore, prevent the expansion of $a from being considered an
assignment.  Update test expectations accordingly.
2020-02-22 15:12:24 +00:00
Daniel Shahaf
3558306149 tests: Add tests for issue #670.
Before the parent commit, they behaved as follows:

    ZSH_PATCHLEVEL=debian/5.7.1-1
    # parameter-value-contains-command-position1
    1..2
    ok 1 - [1,7] «$foobar» - # TODO "issue #670"
    not ok 2 - have 1 expectations and 6 region_highlight entries: «expected_region_highlight=( '1 7 assign "issue ♯670"' )» «region_highlight=( '0 7 assign' '2 7 default' '2 7 command-substitution-unquoted'
    zsh-syntax-highlighting: BUG: _zsh_highlight_highlighter_main_paint: start(2) >= end(2)
    Bail out! On './highlighters/main/test-data/parameter-value-contains-command-position2.zsh': output on stderr
    # parameter-value-contains-command-position2
    1..2
    ok 1 - [1,2] «$y» - # TODO "issue #670"
    ok 2 - cardinality check

Due to the the "BUG:" and "Bail out!" on the first one, they could not
be added as XFAIL tests before the parent commit.
2020-02-22 15:12:24 +00:00
Daniel Shahaf
1a55dc8fc2 'main': Pass parameters through the multi-word machinery, as we already do for aliases.
Fixes #674.
2020-02-22 15:12:24 +00:00
Daniel Shahaf
52ea5c686a 'main': precommands += chronic, ifne (from moreutils)
Fixes #681.
2020-02-17 10:20:13 +00:00
Manaswini Das
dde84e1b25 docs: Fix typo
Fixes #679
2020-01-28 07:44:52 +00:00
Matthew Martin
0e51046b19 main: Add tests for issue #678 2020-01-25 15:51:16 -06:00
Daniel Shahaf
4e92449752 changelog: Document #670 as a known issue. 2020-01-25 21:00:40 +00:00
Daniel Shahaf
b73853dd96 changelog: Document #677 as a known issue. 2020-01-24 18:40:51 +00:00
Daniel Shahaf
4546756500 tests: Fix another instance of issue from the last commit. 2020-01-24 01:22:03 +00:00
Daniel Shahaf
9d380805d7 tests: Unbreak the build on zsh 5.0.8 and older. 2020-01-24 00:51:27 +00:00
Daniel Shahaf
deee22ed42 tests: Don't filter out tests that aborted.
Useful in piping Travis CI output through tap-filter manually.
2020-01-24 00:49:51 +00:00
Daniel Shahaf
77c6bf2019 'main': precommands: Remove argumentless options that can't be followed by a command word.
Suggested-by: Matthew Martin
(in e2e97dde9c (r36941988))
2020-01-24 00:37:56 +00:00
Daniel Shahaf
27e4789439 docs: Track FreeBSD port rename
See https://svnweb.freebsd.org/ports?revision=501751&view=revision
2020-01-23 22:09:33 +00:00
Daniel Shahaf
e2e97dde9c 'main': Support tabbed(1) from suckless-tools 2020-01-22 04:44:27 +00:00
Daniel Shahaf
9bf06c5c2a tests: Add a regression test for issue #676. 2020-01-20 03:49:00 +00:00
Daniel Shahaf
dfb917020c Bump copyright years. 2020-01-16 17:19:25 +00:00
Daniel Shahaf
9ed2a46ed2 dev tools: New script to ease opening $EDITOR on failing tests.
Has room for improvement; for now, I use it with CTRL-W_f.
2020-01-16 17:19:25 +00:00
Daniel Shahaf
1c6a6d92b0 dev tools: Allow specifying preamble code when generating test cases. 2020-01-16 17:19:25 +00:00
Daniel Shahaf
6b0671b63e Add .editorconfig file.
Vim doesn't honour the modelines by default because they're too far from
the start/end of the file [the default value of the 'modelines' (sic)
option is too small].
2020-01-16 17:19:25 +00:00
Daniel Shahaf
b3b6d7129f tests: Add failing tests for issue #674. 2020-01-16 16:12:14 +00:00
Daniel Shahaf
9cb7e9a837 tests: Make sudo-longopt pass when sudo isn't installed.
Fixes #673.
2020-01-16 15:49:27 +00:00
Daniel Shahaf
cb166dcc77 'main': Restore 0.6.0's behaviour for unknown options.
See discussion on #664.
2020-01-14 23:08:50 +00:00
Daniel Shahaf
5012d771f3 'main': Don't highlight unknown precommand flags as errors.
We cannot now for sure whether the flag is misspelled or simply unknown to us,
so err on the side of caution.  This fixes an unreleased regression.  Fixes #658.

Issue #641 was originally filed about this problem, but is left open to track
further enhancements.
2020-01-14 23:08:50 +00:00
Daniel Shahaf
3a6f7e7bfe 'main': Add an XFail test for #641 and #658. 2020-01-14 23:08:50 +00:00
Daniel Shahaf
b1f36d9c5f 'main': Add a comment. 2020-01-12 19:48:49 +00:00
Daniel Shahaf
08edf8db7f 'main': Fix the $CDPATH from the previous commit. 2020-01-12 19:37:53 +00:00
Daniel Shahaf
6629a1f432 'main': Add a test for a $CDPATH bug. 2020-01-12 19:37:30 +00:00
Daniel Shahaf
521fedfdf5 'main': Change the issue a test is associated with.
Issue #202 is too overloaded.
2020-01-12 19:32:44 +00:00
Daniel Shahaf
1618848df6 'main': Add some tests for complete and partial absolute paths in command position. 2020-01-12 19:29:46 +00:00
Daniel Shahaf
c3293ba0d8 'main': Update comments after last commit. No functional change. 2020-01-12 18:34:49 +00:00
Daniel Shahaf
21cdd6bc5e 'main': Simplify alias handling.
$last_alias isn't needed; there's no reason to treat loops of length 2
(alias a=b b=a) differently to loops of length 1 (alias a=a), length 3
(alias a=b b=c c=a), or length N.

The «(( $+seen_alias[$arg] ))» check is redundant as of the last commit:
the enclosing condition ensures that $res is "alias", which implies that
«(( $+seen_alias[$arg] ))» is false.
2020-01-12 18:34:49 +00:00
Daniel Shahaf
f32d1704b1 'main': Fix issue #652. 2020-01-12 18:34:49 +00:00
Daniel Shahaf
86fe054005 'main': precommands += ssh-agent 2020-01-12 17:21:59 +00:00
Daniel Shahaf
533bfa0116 'main': Fix the new 'backslash' test on zsh-5.0.2 and older. (The bug
occurred on zsh-5.0.7 and older but I don't have zsh-5.0.7 handy to test
on.)

Evidently, the issue was due to elision.

This addresses #665.0 and #665.5.
2020-01-12 17:10:34 +00:00
Daniel Shahaf
2d0dddf58b 'main': Don't dequote the word in command position before analyzing it.
Fixes #656.
Fixes #660.

Regression from commit e1ecf950e2,
"main: Do path expanstion after alias expansion" (sic).
2020-01-12 16:11:09 +00:00
Daniel Shahaf
27fa4a6546 noop: Quote the bitflag values.
Now every instance of «:foo:» is ''-quoted.  This enables $EDITOR to highlight
them consistently throughout the file.
2020-01-12 15:46:22 +00:00
Daniel Shahaf
ae5ad09cf5 Bump copyright years. 2020-01-12 14:58:56 +00:00
Daniel Shahaf
3ee5aa0e06 release.md: Add missing argument. 2020-01-11 23:43:23 +00:00
Daniel Shahaf
eb277cdcc6 Post-release version number bump. 2020-01-11 23:42:31 +00:00
Daniel Shahaf
71dc090d02 Tag version 0.7.0-beta1. 2020-01-11 23:34:58 +00:00
Daniel Shahaf
6a310ada5b changelog: Add three entries 2020-01-11 23:31:18 +00:00
Daniel Shahaf
c1d5790c57 changelog: Start 0.7.0's changelog. 2020-01-11 23:10:28 +00:00
Daniel Shahaf
e9b1ce1a36 Add a unit test for dc1b2f6fa4. 2020-01-11 23:04:22 +00:00
Daniel Shahaf
68fbe1a449 Add a test for redirection from/to process substitution.
Inspired by ab1013ae0d.
2020-01-11 21:47:34 +00:00
Daniel Shahaf
f02c0bf980 Don't describe as ZSH_HIGHLIGHT_DIRS_BLACKLIST as experimental, now that it's named without the X_ prefix. 2020-01-11 21:32:21 +00:00
Daniel Shahaf
1be58a6f45 Add a test for 2f03b6d704. 2020-01-11 21:19:52 +00:00
Daniel Shahaf
c0ad50e645 dev tools: Fix regression introduced in commit "Print the test data to stdout for convenience.".
tee(1) truncated $fname.  Fortunately, the data that got truncated had just
been `git add`-ed, so no harm was done.
2020-01-11 20:49:12 +00:00
Daniel Shahaf
8b2768ab40 'main': Add a test for 07f259f653. 2020-01-11 20:46:14 +00:00
Daniel Shahaf
6f1f595e3e dev tools: Print the test data to stdout for convenience. 2020-01-07 19:59:49 +00:00
Daniel Shahaf
de95d50bce 'main': Fix highlighting of the 'time' and 'nocorrect reserved words
Also add tests.

'time' is a regression from 6647e88606
(last Wednesday).
2019-12-27 13:47:31 +00:00
Daniel Shahaf
83862c1abb 'main': Add two basic tests for aliases. 2019-12-27 09:37:23 +00:00
Daniel Shahaf
ce10f20e77 'main': Add a regression test for #652. 2019-12-27 09:00:36 +00:00
Daniel Shahaf
6647e88606 'main': Add some precommands. 2019-12-25 10:53:42 +00:00
Daniel Shahaf
b7592e581d tests: Minor documentation readability tweak 2019-11-10 11:49:47 +00:00
Daniel Shahaf
926c36c1fb Add a test for issue #641.5, using the infrastructure added in the previous commits.
Current output:
.
    # precommand-then-assignment
    1..4
    ok 1 - [1,4] «nice»
    not ok 2 - [6,8] «x=y» - expected (6 8 "unknown-token"), observed (6 8 "assign"). # TODO "issue #641.5"
    not ok 3 - [8,8] «y» - expected (10 11 "default"), observed (8 8 "default"). # TODO "issue #641.5 (fallout)"
    ok 4 - cardinality check # SKIP cardinality check disabled whilst regular test points are expected to fail
2019-11-10 11:49:26 +00:00
Daniel Shahaf
4952325051 tests: Skip cardinality tests whenever any test point is expected to fail.
When writing an expected-to-fail test case, the cardinality of $region_highlight
at the time the test is written may differ from the cardinality it will have
once the bug is fixed.  For example, with issue #641.5, the current highlighting
is ['nice', 'x=y', 'y', 'ls'] — four elements — but the correct highlighting
would have three elements: ['nice', 'x=y', 'ls'].  There is no point in reporting
a separate test failure for the cardinality check in this case, nor for 'ls' being
highlighted as 'command' rather than 'default'.

At the same time, in other cases the current and correct highlighting may have the
same number of elements (for example, this would be the case for a hypothetical
"the command word is highlighted as an alias rather than a function" bug).  Thus,
the previous commit, q.v..
2019-11-10 11:49:13 +00:00
Daniel Shahaf
d5a4a6e195 tests: Make $expected_mismatch skip the cardinality check, rather
than consider it an expected failure.

With this change, if $expected_region_highlight and $region_highlight
coincidentally have the same number of elements, the test won't be considered
to fail.

This is useful in conjunction with the next commit, q.v..

At this time, no tests set $expected_mismatch explicitly.  However, the
commit after next (this commit's grandchild) will add a test that will
set $expected_mismatch implicitly, using the functionality in the next
commit (this commit's child).
2019-11-10 11:48:40 +00:00
Daniel Shahaf
e209cbe61a tests: Include the name of the 'cardinality check' test point in the output 2019-11-10 11:20:21 +00:00
Matthew Martin
e7d3fbc50b main: Add test for previous 2019-11-07 19:59:00 -06:00
Matthew Martin
139ea2b189 main: Avoid $end_pos when calculating $arg size
Fixes second issue filed under #617
https://github.com/zsh-users/zsh-syntax-highlighting/issues/617#issuecomment-551253422

In the case of a command substitution in an alias, $arg[i,end_pos] would
not pass to the end of $arg and i <= start_pos - end_pos would not
iterate over all of $arg. Use $arg[i,-1] and $#arg respectively to avoid
issues in aliases.
2019-11-07 19:50:17 -06:00
Oliver Kiddle
be3882aeb0 driver: adjust region end for vi command mode 2019-10-17 21:18:56 +00:00
Daniel Shahaf
35c8690c00 release.md: Document that release tags should be signed.
That's how the previous tags were done.
2019-08-01 15:02:07 +00:00
Matthew Martin
b55832c5f8 main: Drop X_ from X_ZSH_HIGHLIGHT_DIRS_BLACKLIST 2019-07-24 07:27:54 -05:00
Daniel Shahaf
8e78e9dbba 'main': Fix issue #623 by fixing the expectations of the regression test of issue #616. 2019-07-21 01:44:19 +00:00
Matthew Martin
8d4c6355e6 driver: Do not pass widget arguments to _zsh_highlight
This avoids a bug in zsh 4.3.12 and prior which affects passing
arguments to an anonymous function.
2018-10-13 21:55:45 -05:00
Daniel Shahaf
56ba7f082d driver: Clarify comment. No functional change. 2018-10-12 12:35:34 -05:00
Matthew Martin
2cbb3fb24e driver: Allow for -U in autoloaded function definition 2018-10-12 12:35:34 -05:00
Matthew Martin
f265ef0b9a driver: Use idiomatic module check 2018-10-12 12:35:34 -05:00
Daniel Shahaf
d0fb0df4ff driver: Make the shadowing $WIDGET read only. 2018-10-12 12:35:34 -05:00
Daniel Shahaf
f665eec230 driver: Avoid a fork in the common case.
Found-by: Matthew Martin
2018-10-12 12:35:34 -05:00
Daniel Shahaf
a868b6942e test harness: Actually test the new code.
Currently, without zsh/zle loaded, the tests silently fall back to the
5.2-and-earlier codepath; see:
.
    https://github.com/zsh-users/zsh-syntax-highlighting/pull/356#issuecomment-243651251
2018-10-12 12:35:34 -05:00
Daniel Shahaf
b5249f17ab driver: Rewrite without a state variable
Suggested-by: m0viefreak
2018-10-12 12:35:32 -05:00
Daniel Shahaf
d2594c1157 noop: Make a whitespace-only change to reduce noise in the next commit. 2018-10-12 12:31:12 -05:00
Daniel Shahaf
66ae59eccc docs: Rewrap. 2018-10-12 12:31:12 -05:00
Daniel Shahaf
1651137f5c docs: Update FAQ answer per changes on this branch. 2018-10-12 12:31:12 -05:00
Daniel Shahaf
d4ab7e51d2 redo _zsh_highlight__function_callable_p 2018-10-12 12:31:12 -05:00
Daniel Shahaf
38477f2a3d driver: Use a different way of checking whether add-zle-hook-widget is present.
Based on code by Bart Schaefer (reference within).

Tested with zsh 5.0.7-5 (debian package) and with 5b4cbcc842c6 (39158,
5.3-to-be of today).
2018-10-12 12:31:12 -05:00
Daniel Shahaf
d98622dcd0 changelog: Use a more specific link. 2018-10-12 12:31:12 -05:00
Daniel Shahaf
04fd6bbf53 changelog: Note the effect of fixing #245/#90 and an alternative. 2018-10-12 12:31:12 -05:00
Daniel Shahaf
30c6e70394 driver: Pass zle-line-finish arguments on to _zsh_highlight.
(Currently a noop)
2018-10-12 12:31:12 -05:00
Daniel Shahaf
74a27de70d driver: Hook zle-line-finish.
Compare issue #288.
2018-10-12 12:31:10 -05:00
Daniel Shahaf
85e62a8171 driver: Reimplement using 'add-zle-hook-widget zle-line-pre-redraw'
This feature will be released in zsh 5.3.  Older zsh's will use the existing
codepath.
2018-10-12 12:30:23 -05:00
Daniel Shahaf
aed99f6a3e wrappers: Reimplement using Mikachu's zle-line-pre-redraw hook (workers/36650). 2018-10-11 22:04:02 -05:00
150 changed files with 5658 additions and 521 deletions

15
.editorconfig Normal file
View File

@ -0,0 +1,15 @@
# Top-most editorconfig file
root = true
[*]
end_of_line = lf
tab_width = 2
indent_size = 2
indent_style = space
[Makefile]
tab_width = 8
indent_size = 8
indent_style = tab

75
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,75 @@
---
name: Tests
on:
push:
paths-ignore:
- '**.md'
- '**.png'
pull_request:
paths-ignore:
- '**.md'
- '**.png'
schedule:
- cron: '29 7 * * 1'
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version:
- master
- 5.9
- 5.8.1
- 5.8
- 5.7.1
- 5.7
- 5.6.2
- 5.6.1
- 5.6
- 5.5.1
- 5.5
- 5.4.2
- 5.4.1
- 5.4
- 5.3.1
- 5.3
- 5.2
- 5.1.1
- 5.1
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.3.17
- 4.3.16
- 4.3.15
- 4.3.14
- 4.3.13
- 4.3.12
- 4.3.11
container:
image: ghcr.io/zsh-users/zsh:${{ matrix.version }}
steps:
- uses: actions/checkout@v4
- run: install_packages bsdmainutils make procps
- run: make test
notify:
runs-on: ubuntu-latest
needs: test
if: failure() && (github.repository_owner == 'zsh-users')
steps:
-
name: Notify IRC
uses: Gottox/irc-message-action@v2
with:
channel: '#zsh-syntax-highlighting'
nickname: zsyh-gh-bot
message: '${{ github.ref }} failed tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'

View File

@ -1,55 +0,0 @@
language: generic
sudo: required
env:
- ZSH=master
- ZSH=5.7.1
- ZSH=5.7
- 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
- ZSH=5.3.1
- ZSH=5.3
- ZSH=5.2
- ZSH=5.1.1
- ZSH=5.1
- ZSH=5.0.8
- ZSH=5.0.7
- ZSH=5.0.6
- ZSH=5.0.5
- ZSH=5.0.4
- ZSH=5.0.3
- ZSH=5.0.2
- ZSH=5.0.1
- ZSH=5.0.0
- ZSH=4.3.17
- ZSH=4.3.16
- ZSH=4.3.15
- ZSH=4.3.14
- ZSH=4.3.13
- ZSH=4.3.12
- ZSH=4.3.11
script: docker run -v $PWD:/work -w /work zshusers/zsh:${ZSH} /bin/sh -c 'install_packages make procps && make test'
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/367e241cdea60cb2070b
on_success: change
on_failure: always
on_start: never
irc:
channels:
- "chat.freenode.net#zsh-syntax-highlighting"
on_success: change
on_failure: always
on_start: never
use_notice: true
template:
- "%{repository}/%{branch}#%{build_number}: %{message} Changes : %{compare_url} | Build : %{build_url}"

View File

@ -1 +1 @@
0.7.0-dev
0.8.1-dev

View File

@ -1,4 +1,4 @@
Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
Copyright (c) 2010-2020 zsh-syntax-highlighting contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted

View File

@ -67,6 +67,22 @@ expected_region_highlight=(
)
```
Memos and commas
----------------
We append to `region_highlight` as follows:
```zsh
region_highlight+=("$start $end $spec, memo=zsh-syntax-highlighting")
```
That comma is required to cause zsh 5.8 and older to ignore the memo without
ignoring the `$spec`. It's a hack, but given that no further 5.8.x patch
releases are planned, it's been deemed acceptable. See issue #418 and the
cross-referenced issues.
Miscellany
----------
@ -79,5 +95,5 @@ zstyle ':completion:*:*:*:*:globbed-files' ignored-patterns {'*/',}zsh-syntax-hi
IRC channel
-----------
We're on #zsh-syntax-highlighting on freenode.
We're on #zsh-syntax-highlighting on Libera.Chat.

View File

@ -3,31 +3,67 @@ How to install
### Using packages
First, install the package:
* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-package]
* Debian: `zsh-syntax-highlighting` package [in `stretch`][debian-package] (or in [OBS repository][obs-repository])
* Fedora: [zsh-syntax-highlighting package][fedora-package-alt] in Fedora 24+ (or in [OBS repository][obs-repository])
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`textproc/zsh-syntax-highlighting`][freebsd-port])
* Gentoo: [mv overlay][gentoo-overlay]
* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package]
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])
* RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port])
* Gentoo: [app-shells/zsh-syntax-highlighting][gentoo-repository]
* Mac OS X / Homebrew: `brew install zsh-syntax-highlighting` ([formula][brew-package])
* NetBSD: `pkg_add zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][netbsd-port])
* OpenBSD: `pkg_add zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][openbsd-port])
* openSUSE / SLE: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
* RHEL / CentOS / Scientific Linux: `zsh-syntax-highlighting` package in [OBS repository][obs-repository]
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])
* Void Linux: `zsh-syntax-highlighting package` [in XBPS][void-package]
[arch-package]: https://www.archlinux.org/packages/zsh-syntax-highlighting
[AUR-package]: https://aur.archlinux.org/packages/zsh-syntax-highlighting-git
[brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/z/zsh-syntax-highlighting.rb
[debian-package]: https://packages.debian.org/zsh-syntax-highlighting
[freebsd-port]: http://www.freshports.org/textproc/zsh-syntax-highlighting/
[gentoo-overlay]: http://gpo.zugaina.org/app-shells/zsh-syntax-highlighting
[brew-package]: https://github.com/Homebrew/homebrew-core/blob/master/Formula/zsh-syntax-highlighting.rb
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
[fedora-package]: https://apps.fedoraproject.org/packages/zsh-syntax-highlighting
[fedora-package-alt]: https://bodhi.fedoraproject.org/updates/?packages=zsh-syntax-highlighting
[obs-repository]: https://software.opensuse.org//download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
[freebsd-port]: https://www.freshports.org/textproc/zsh-syntax-highlighting/
[gentoo-repository]: https://packages.gentoo.org/packages/app-shells/zsh-syntax-highlighting
[netbsd-port]: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/shells/zsh-syntax-highlighting/
[obs-repository]: https://software.opensuse.org/download.html?project=shells%3Azsh-users%3Azsh-syntax-highlighting&package=zsh-syntax-highlighting
[openbsd-port]: https://cvsweb.openbsd.org/ports/shells/zsh-syntax-highlighting/
[ubuntu-package]: https://launchpad.net/ubuntu/+source/zsh-syntax-highlighting
[void-package]: https://github.com/void-linux/void-packages/tree/master/srcpkgs/zsh-syntax-highlighting
See also [repology's cross-distro index](https://repology.org/metapackage/zsh-syntax-highlighting/versions)
Second, enable zsh-syntax-highlighting by sourcing the script. Running this command on the terminal will add the source line to the end of your .zshrc:
* On most Linux distributions (except perhaps NixOS):
```zsh
echo "source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
```
* NetBSD and OpenBSD:
```zsh
echo "source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
```
* Mac OS X / Homebrew:
```zsh
echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc
```
Then restart zsh (such as by opening a new instance of your terminal emulator).
Alternatively, add the `source` command manually **at the end** of your `.zshrc`:
* On most Linux distributions (except perhaps NixOS):
`source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh`
* NetBSD and OpenBSD:
`source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh`
Then restart zsh.
### In your ~/.zshrc
@ -71,6 +107,12 @@ This list is incomplete as there are too many
Add `antigen bundle zsh-users/zsh-syntax-highlighting` as the last bundle in
your `.zshrc`.
#### [Fig](https://fig.io)
Click the `Install Plugin` button on the [Fig plugin page][fig-plugin].
[fig-plugin]: https://fig.io/plugins/other/zsh-syntax-highlighting
#### [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
1. Clone this repository in oh-my-zsh's plugins directory:
@ -98,15 +140,15 @@ Zsh-syntax-highlighting is included with Prezto. See the
Add `zgen load zsh-users/zsh-syntax-highlighting` to the end of your `.zshrc`.
#### [zinit](https://github.com/zdharma-continuum/zinit)
Add `zinit light zsh-users/zsh-syntax-highlighting` to the end of your
`.zshrc`.
#### [zplug](https://github.com/zplug/zplug)
Add `zplug "zsh-users/zsh-syntax-highlighting", defer:2` to your `.zshrc`.
#### [zplugin](https://github.com/psprint/zplugin)
Add `zplugin load zsh-users/zsh-syntax-highlighting` to the end of your
`.zshrc`.
### System-wide installation

View File

@ -41,7 +41,7 @@ test:
for test in highlighters/*; do \
if [ -d $$test/test-data ]; then \
echo "Running test $${test##*/}"; \
$(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
env -i QUIET=$$QUIET $${TERM:+"TERM=$$TERM"} $(ZSH) -f tests/test-highlighting.zsh "$${test##*/}"; \
: $$(( result |= $$? )); \
fi \
done; \

View File

@ -1,12 +1,12 @@
zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis]
zsh-syntax-highlighting [![Build Status][build-status-image]][build-status]
=======================
**[Fish shell][fish]-like syntax highlighting for [Zsh][zsh].**
*Requirements: zsh 4.3.11+.*
[fish]: http://www.fishshell.com/
[zsh]: http://www.zsh.org/
[fish]: https://fishshell.com/
[zsh]: https://www.zsh.org/
This package provides syntax highlighting for the shell zsh. It enables
highlighting of commands whilst they are typed at a zsh prompt into an
@ -27,6 +27,11 @@ Before: [![Screenshot #3.1](images/before3-smaller.png)](images/before3.png)
<br/>
After:&nbsp; [![Screenshot #3.2](images/after3-smaller.png)](images/after3.png)
Before: [![Screenshot #4.1](images/before4-smaller.png)](images/before4-smaller.png)
<br/>
After:&nbsp; [![Screenshot #4.2](images/after4-smaller.png)](images/after4-smaller.png)
How to install
--------------
@ -39,11 +44,23 @@ FAQ
### Why must `zsh-syntax-highlighting.zsh` be sourced at the end of the `.zshrc` file?
`zsh-syntax-highlighting.zsh` wraps ZLE widgets. It must be sourced after all
custom widgets have been created (i.e., after all `zle -N` calls and after
running `compinit`). Widgets created later will work, but will not update the
zsh-syntax-highlighting works by hooking into the Zsh Line Editor (ZLE) and
computing syntax highlighting for the command-line buffer as it stands at the
time z-sy-h's hook is invoked.
In zsh 5.2 and older,
`zsh-syntax-highlighting.zsh` hooks into ZLE by wrapping ZLE widgets. It must
be sourced after all custom widgets have been created (i.e., after all `zle -N`
calls and after running `compinit`) in order to be able to wrap all of them.
Widgets created after z-sy-h is sourced will work, but will not update the
syntax highlighting.
In zsh newer than 5.8 (not including 5.8 itself),
zsh-syntax-highlighting uses the `add-zle-hook-widget` facility to install
a `zle-line-pre-redraw` hook. Hooks are run in order of registration,
therefore, z-sy-h must be sourced (and register its hook) after anything else
that adds hooks that modify the command-line buffer.
### Does syntax highlighting work during incremental history search?
Highlighting the command line during an incremental history search (by default bound to
@ -56,7 +73,7 @@ enough information to allow computing the highlighting correctly.)
See issues [#288][i288] and [#415][i415] for details.
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[i288]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/288
[i415]: https://github.com/zsh-users/zsh-syntax-highlighting/pull/415
@ -76,5 +93,5 @@ Syntax highlighting is done by pluggable highlighter scripts. See the
[documentation on highlighters](docs/highlighters.md) for details and
configuration settings.
[build-status-image]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting.svg?branch=master
[build-status-travis]: https://travis-ci.org/zsh-users/zsh-syntax-highlighting
[build-status]: https://github.com/zsh-users/zsh-syntax-highlighting/actions
[build-status-image]: https://github.com/zsh-users/zsh-syntax-highlighting/workflows/Tests/badge.svg

View File

@ -1,3 +1,315 @@
# Changes in HEAD
- Highlight `&>` `>&|` `>&!` `&>|` and `&>!` as redirection.
[#942]
# Changes in 0.8.0
This is a stable bugfix and feature release. Major new features and changes include:
## Changes fixed as part of the switch to zle-line-pre-redraw
The changes in this section were fixed by switching to a `zle-line-pre-redraw`-based
implementation.
Note: The new implementation will only be used on future zsh releases,
numbered 5.8.1.1 and newer, due to interoperability issues with other plugins
(issues #418 and #579). The underlying zsh feature has been available since
zsh 5.3.
Whilst under development, the new implementation was known as the
"feature/redrawhook" topic branch.
- Fixed: Highlighting not triggered after popping a buffer from the buffer stack
(using the `push-line` widget, default binding: `M-q`)
[#40]
- Fixed: Invoking completion when there were no matches removed highlighting
[#90, #470]
- Fixed: Two successive deletes followed by a yank only yanked the latest
delete, rather than both of them
[#150, #151, #160; cf. #183]
- Presumed fixed: Completing `$(xsel)` results in an error message from `xsel`,
with pre-2017 versions of `xsel`. (For 2017 vintage and newer, see the issue
for details.)
[#154]
- Fixed: When the standard `bracketed-paste-magic` widget is in use, pastes were slow
[#295]
- Fixed: No way to prevent a widget from being wrapped
[#324]
- Fixed: No highlighting while cycling menu completion
[#375]
- Fixed: Does not coexist with the `IGNORE_EOF` option
[#377]
- Fixed: The `undefined-key` widget was wrapped
[#421]
- Fixed: Does not coexist with the standard `surround` family of widgets
[#520]
- Fixed: First completed filename doesn't get `path` highlighting
[#632]
## Other changes
- Add issue #712 to the previous release's changelog (hereinafter).
- Fix highlighting when using an alias twice inside another alias
[#769, #775]
- Remove lint warning for `env` followed by a pipe
[#797]
- Recognize `proxychains` as a precommand
[#814, #914]
- Honor shwordsplit when expanding parameters
[#687, #818]
- Skip highlighting when keys are still pending in more cases
[#835]
- Recognize `grc` as a precommand
- Recognize `torsocks` and `torift` as precommands
[#898]
- Recognize `cpulimit` as a precommand
[#897]
- Recognize `ktrace` as a precommand
# Changes in 0.8.0-alpha1-pre-redrawhook
## Notice about an improbable-but-not-impossible forward incompatibility
Everyone can probably skip this section.
The `master` branch of zsh-syntax-highlighting uses a zsh feature that has not
yet appeared in a zsh release: the `memo=` feature, added to zsh in commit
zsh-5.8-172-gdd6e702ee (after zsh 5.8, before zsh 5.9). In the unlikely event
that this zsh feature should change in an incompatible way before the next
stable zsh release, set `zsh_highlight__memo_feature=0` in your .zshrc files to
disable use of the new feature.
z-sy-h dogfoods the new, unreleased zsh feature because that feature was
added to zsh at z-sy-h's initiative. The new feature is used in the fix
to issue #418.
## Incompatible changes:
- An unsuccessful completion (a <kbd>⮀ Tab</kbd> press that doesn't change the
command line) no longer causes highlighting to be lost. Visual feedback can
alternatively be achieved by setting the `format` zstyle under the `warnings`
tag, for example,
zstyle ':completion:*:warnings' format '%F{red}No matches%f'
Refer to the [description of the `format` style in `zshcompsys(1)`]
[zshcompsys-Standard-Styles-format].
(#90, part of #245 (feature/redrawhook))
[zshcompsys-Standard-Styles]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Standard-Styles
[zshcompsys-Standard-Styles-format]: https://zsh.sourceforge.io/Doc/Release/Completion-System.html#index-format_002c-completion-style
## Other changes:
- Document `$ZSH_HIGHLIGHT_MAXLENGTH`.
[#698]
- Optimize highlighting unquoted words (words that are not in single quotes, double quotes, backticks, or dollar-single-quotes)
[#730]
- Redirection operators (e.g., `<` and `>`) are now highlighted by default
[#646]
- Propertly terminate `noglob` scope in try/always blocks
[#577]
- Don't error out when `KSH_ARRAYS` is set in the calling scope
[#622, #689]
- Literal semicolons in array assignments (`foo=( bar ; baz )`) are now
highlighted as errors.
[3ca93f864fb6]
- Command separators in array assignments (`foo=( bar | baz )`) are now
highlighted as errors.
[#651, 81267ca3130c]
- Support parameter elision in command position (e.g., `$foo ls` where `$foo` is unset or empty)
[#667]
- Don't consider the filename in `sudo -e /path/to/file` to be a command position
[#678]
- Don't look up absolute directory names in $cdpath
[2cc2583f8f12, part of #669]
- Fix `exec 2>&1;` being highlighted as an error.
[#676]
- Fix `: $(<*)` being highlighted as globbing.
[#582]
- Fix `cat < *` being highlighting as globbing when the `MULTIOS` option is unset.
[#583]
- Fix `echo >&2` highlighting the `2` as a filename if a file by that name happened to exist
[#694, part of #645]
- Fix `echo >&-` highlighting the `-` as a filename if a file by that name happened to exist
[part of #645]
- Fix `echo >&p` highlighting the `p` as a filename if a file by that name happened to exist
[part of #645]
- Fix wrong highlighting of unquoted parameter expansions under zsh 5.2 and older
[e165f18c758e]
- Highlight global aliases
[#700]
- Highlight `: =nosuchcommand' as an error (when the `EQUALS` option hasn't been unset).
[#430]
- Highlight reserved word after assignments as errors (e.g., `foo=bar (ls;)`)
[#461]
- Correctly highlight `[[ foo && bar || baz ]]`.
- Highlight non-executable files in command position correctly (e.g., `% /etc/passwd`)
[#202, #669]
- Highlight directories in command position correctly, including `AUTO_CD` support
[#669]
- Recognize `env` as a precommand (e.g., `env FOO=bar ls`)
- Recognize `ionice` as a precommand
- Recognize `strace` as a precommand
- Fix an error message on stderr before every prompt when the `WARN_NESTED_VAR` zsh option is set:
`_zsh_highlight_main__precmd_hook:1: array parameter _zsh_highlight_main__command_type_cache set in enclosing scope in function _zsh_highlight_main__precmd_hook`
[#727, #731, #732, #733]
- Fix highlighting of alias whose definitions use a simple command terminator
(such as `;`, `|`, `&&`) before a newline
[#677; had regressed in 0.7.0]
- Highlight arithmetic expansions (e.g., `$(( 42 ))`)
[#607 #649 #704]
- Highlight the parentheses of array assignments as reserved words (`foo=( bar )`).
The `assign` style remains supported and has precedence.
[#585]
- Fix interoperability issue with other plugins that use highlighting. The fix
requires zsh 5.8.0.3 or newer. (zsh 5.8.0.2-dev from the `master` branch,
revision zsh-5.8-172-gdd6e702ee or newer is also fine.)
[#418, https://github.com/okapia/zsh-viexchange/issues/1]
- Improve performance of the `brackets` highlighter.
- Fix highlighting of pre-command redirections (e.g., the `$fn` in `<$fn cat`)
[#712]
# Changes in version 0.7.1
- Remove out-of-date information from the 0.7.0 changelog.
# Changes in version 0.7.0
This is a stable bugfix and feature release. Major new features and changes include:
- Add `ZSH_HIGHLIGHT_DIRS_BLACKLIST` to disable "path" and "path prefix"
highlighting for specific directories
[#379]
- Add the "regexp" highlighter, modelled after the pattern highlighter
[4e6f60063f1c]
- When a word uses globbing, only the globbing metacharacters will be highlighted as globbing:
in `: foo*bar`, only the `*` will be blue.
[e48af357532c]
- Highlight pasted quotes (e.g., `: foo"bar"`)
[dc1b2f6fa4bb]
- Highlight command substitutions (`` : `ls` ``, `: $(ls)`)
[c0e64fe13178 and parents, e86f75a840e7, et al]
- Highlight process substitutions (`: >(nl)`, `: <(pwd)`, `: =(git diff)`)
[c0e64fe13178 and parents, e86f75a840e7, et al]
- Highlight command substitutions inside double quotes (``: "`foo`"``)
[f16e858f0c83]
- Highlight many precommands (e.g., `nice`, `stdbuf`, `eatmydata`;
see `$precommand_options` in the source)
- Highlight numeric globs (e.g., `echo /lib<->`)
- Assorted improvements to aliases highlighting
(e.g.,
`alias sudo_u='sudo -u'; sudo_u jrandom ls`,
`alias x=y y=z z=nosuchcommand; x`,
`alias ls='ls -l'; \ls`)
[f3410c5862fc, 57386f30aec8, #544, and many others]
- Highlight some more syntax errors
[dea05e44e671, 298ef6a2fa30]
- New styles: named file descriptors, `RC_QUOTES`, and unclosed quotes (e.g., `echo "foo<CURSOR>`)
[38c794a978cd, 25ae1c01216c, 967335dfc5fd]
- The 'brackets' highlighting no longer treats quotes specially.
[ecdda36ef56f]
Selected bugfixes include:
- Highlight `sudo` correctly when it's not installed
[26a82113b08b]
- Handle some non-default options being set in zshrc
[b07ada1255b7, a2a899b41b8, 972ad197c13d, b3f66fc8748f]
- Fix off-by-one highlighting in vi "visual" mode (vicmd keymap)
[be3882aeb054]
- The 'yank-pop' widget is not wrapped
[#183]
Known issues include:
- A multiline alias that uses a simple command terminator (such as `;`, `|`, `&&`)
before a newline will incorrectly be highlighted as an error. See issue #677
for examples and workarounds.
[#677]
[UPDATE: Fixed in 0.8.0]
# Changes in version 0.6.0
This is a stable release, featuring bugfixes and minor improvements.
@ -13,7 +325,7 @@ This is a stable release, featuring bugfixes and minor improvements.
- The `isearch` and `suffix` [`$zle_highlight` settings][zshzle-Character-Highlighting].
(79e4d3d12405, 15db71abd0cc, b56ee542d619; requires zsh 5.3 for `$ISEARCHMATCH_ACTIVE` / `$SUFFIX_ACTIVE` support)
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
- Possible history expansions in double-quoted strings.
(76ea9e1df316)
@ -459,7 +771,7 @@ in this area.
## Developer-visible changes:
- Test harness converted to [TAP](http://testanything.org/tap-specification.html) format
- Test harness converted to [TAP](https://testanything.org/tap-specification.html) format
(d99aa58aaaef, et seq)
- Run each test in a separate subprocess, isolating them from each other

View File

@ -3,34 +3,51 @@ zsh-syntax-highlighting / highlighters
Syntax highlighting is done by pluggable highlighters:
* `main` - the base highlighter, and the only one [active by default][1].
* `brackets` - [matches brackets][2] and parenthesis.
* `pattern` - matches [user-defined patterns][3].
* `cursor` - matches [the cursor position][4].
* `root` - highlights the whole command line [if the current user is root][5].
* `line` - applied to [the whole command line][6].
* `main` - the base highlighter, and the only one [active by default][main].
* `brackets` - [matches brackets][brackets] and parenthesis.
* `pattern` - matches [user-defined patterns][pattern].
* `regexp` - matches [user-defined regular expressions][regexp].
* `cursor` - matches [the cursor position][cursor].
* `root` - highlights the whole command line [if the current user is root][root].
* `line` - applied to [the whole command line][line].
[1]: highlighters/main.md
[2]: highlighters/brackets.md
[3]: highlighters/pattern.md
[4]: highlighters/cursor.md
[5]: highlighters/root.md
[6]: highlighters/line.md
[main]: highlighters/main.md
[brackets]: highlighters/brackets.md
[pattern]: highlighters/pattern.md
[regexp]: highlighters/regexp.md
[cursor]: highlighters/cursor.md
[root]: highlighters/root.md
[line]: highlighters/line.md
Highlighter-independent settings
--------------------------------
By default, all command lines are highlighted. However, it is possible to
prevent command lines longer than a fixed number of characters from being
highlighted by setting the variable `${ZSH_HIGHLIGHT_MAXLENGTH}` to the maximum
length (in characters) of command lines to be highlighter. This is useful when
editing very long command lines (for example, with the [`fned`][fned] utility
function). Example:
[fned]: https://zsh.sourceforge.io/Doc/Release/User-Contributions.html#index-zed
```zsh
ZSH_HIGHLIGHT_MAXLENGTH=512
```
How to activate highlighters
----------------------------
To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array in
`~/.zshrc`, for example:
To activate an highlighter, add it to the `ZSH_HIGHLIGHT_HIGHLIGHTERS` array.
By default `ZSH_HIGHLIGHT_HIGHLIGHTERS` is `(main)`. For example to activate
`brackets`, `pattern`, and `cursor` highlighters, in `~/.zshrc` do:
```zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor)
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(brackets pattern cursor)
```
By default, `$ZSH_HIGHLIGHT_HIGHLIGHTERS` is unset and only the `main`
highlighter is active.
How to tweak highlighters
-------------------------
@ -42,7 +59,7 @@ 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].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
Some highlighters support additional configuration parameters; see each
highlighter's documentation for details and examples.
@ -104,7 +121,7 @@ To create your own `acme` highlighter:
`_zsh_highlight_highlighter_acme_paint` respectively.
These names are still supported for backwards compatibility;
however, support for them will be removed in a a future major or minor release (v0.x.0 or v1.0.0).
however, support for them will be removed in a future major or minor release (v0.x.0 or v1.0.0).
* Activate your highlighter in `~/.zshrc`:

View File

@ -28,4 +28,4 @@ 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].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting

View File

@ -21,4 +21,4 @@ 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].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting

View File

@ -21,4 +21,4 @@ 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].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting

View File

@ -20,12 +20,14 @@ This highlighter defines the following styles:
* `reserved-word` - shell reserved words (`if`, `for`)
* `alias` - aliases
* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
* `global-alias` - global aliases
* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
* `function` - function names
* `command` - command names
* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
* `commandseparator` - command separation tokens (`;`, `&&`)
* `hashed-command` - hashed commands
* `autodirectory` - a directory name in command position when the `AUTO_CD` option is set
* `path` - existing filenames
* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
* `path_prefix` - prefixes of existing filenames
@ -40,6 +42,7 @@ This highlighter defines the following styles:
* `command-substitution-delimiter-quoted` - a quoted command substitution delimiters (`"$(` and `)"`)
* `process-substitution` - process substitutions (`<(echo foo)`)
* `process-substitution-delimiter` - process substitution delimiters (`<(` and `)`)
* `arithmetic-expansion` - arithmetic expansion `$(( 42 ))`)
* `single-hyphen-option` - single-hyphen options (`-o`)
* `double-hyphen-option` - double-hyphen options (`--option`)
* `back-quoted-argument` - backtick command substitution (`` `foo` ``)
@ -58,7 +61,9 @@ This highlighter defines the following styles:
* `assign` - parameter assignments (`x=foo` and `x=( )`)
* `redirection` - redirection operators (`<`, `>`, etc)
* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
* `named-fd` - named file descriptor (`echo foo {fd}>&2`)
* `comment` - elided parameters in command position (`$x ls` when `$x` is unset or empty)
* `named-fd` - named file descriptor (the `fd` in `echo foo {fd}>&2`)
* `numeric-fd` - numeric file descriptor (the `2` in `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
@ -85,11 +90,10 @@ 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.
To avoid partial path lookups on a path, add the path to the `ZSH_HIGHLIGHT_DIRS_BLACKLIST` array.
```zsh
X_ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
```
### Useless trivia
@ -112,6 +116,6 @@ of that (new) kind will be highlighted by the style `arg0_$kind`,
where `$kind` is the output of `type -w` on the new kind of command word. If that
style is not defined, then the style `arg0` will be used instead.
[zshmisc-Simple-Commands-And-Pipelines]: http://zsh.sourceforge.net/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
[zshmisc-Simple-Commands-And-Pipelines]: https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#Simple-Commands-_0026-Pipelines
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting

View File

@ -21,4 +21,4 @@ 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].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting

View File

@ -11,12 +11,45 @@ To use this highlighter, associate regular expressions with styles in the
`ZSH_HIGHLIGHT_REGEXP` associative array, for example in `~/.zshrc`:
```zsh
typeset -A ZSH_HIGHLIGHT_PATTERNS
ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold)
typeset -A ZSH_HIGHLIGHT_REGEXP
ZSH_HIGHLIGHT_REGEXP+=('^rm .*' fg=red,bold)
```
This will highlight "sudo" only as a complete word, i.e., "sudo cmd", but not
"sudoedit"
This will highlight lines that start with a call to the `rm` command.
The regular expressions flavour used is [PCRE][pcresyntax] when the
`RE_MATCH_PCRE` option is set and POSIX Extended Regular Expressions (ERE),
as implemented by the platform's C library, otherwise. For details on the
latter, see [the `zsh/regex` module's documentation][MAN_ZSH_REGEX] and the
`regcomp(3)` and `re_format(7)` manual pages on your system.
For instance, to highlight `sudo` only as a complete word, i.e., `sudo cmd`,
but not `sudoedit`, one might use:
* When the `RE_MATCH_PCRE` is set:
```zsh
typeset -A ZSH_HIGHLIGHT_REGEXP
ZSH_HIGHLIGHT_REGEXP+=('\bsudo\b' fg=123,bold)
```
* When the `RE_MATCH_PCRE` is unset, on platforms with GNU `libc` (e.g., many GNU/Linux distributions):
```zsh
typeset -A ZSH_HIGHLIGHT_REGEXP
ZSH_HIGHLIGHT_REGEXP+=('\<sudo\>' fg=123,bold)
```
* When the `RE_MATCH_PCRE` is unset, on BSD-based platforms (e.g., macOS):
```zsh
typeset -A ZSH_HIGHLIGHT_REGEXP
ZSH_HIGHLIGHT_REGEXP+=('[[:<:]]sudo[[:>:]]' fg=123,bold)
```
Note, however, that PCRE and POSIX ERE have a large common subset:
for instance, the regular expressions `[abc]`, `a*`, and `(a|b)` have the same
meaning in both flavours.
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)`
@ -25,6 +58,8 @@ 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
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[perlretut]: https://perldoc.perl.org/perlretut
[zshmisc-Conditional-Expressions]: https://zsh.sourceforge.io/Doc/Release/Conditional-Expressions.html#Conditional-Expressions
[MAN_ZSH_REGEX]: https://zsh.sourceforge.io/Doc/Release/Zsh-Modules.html#The-zsh_002fregex-Module
[pcresyntax]: https://www.pcre.org/original/doc/html/pcresyntax.html

View File

@ -22,4 +22,4 @@ 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].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
[zshzle-Character-Highlighting]: https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting

View File

@ -51,8 +51,9 @@ _zsh_highlight_highlighter_brackets_paint()
local -A levelpos lastoflevel matching
# Find all brackets and remember which one is matching
for (( pos = 1; pos <= buflen; pos++ )) ; do
char=$BUFFER[pos]
pos=0
for char in ${(s..)BUFFER} ; do
(( ++pos ))
case $char in
["([{"])
levelpos[$pos]=$((++level))

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'/'
expected_region_highlight=(
'1 1 path_prefix' # /
)

View File

@ -0,0 +1,36 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 autocd
BUFFER=$'/'
expected_region_highlight=(
'1 1 autodirectory' # /
)

View File

@ -0,0 +1,35 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'/bi'
expected_region_highlight=(
'1 3 path_prefix' # /bi
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'/bin; /bin'
expected_region_highlight=(
'1 4 unknown-token' # /bin (in middle)
'5 5 commandseparator' # ;
'7 10 path_prefix' # /bin (at end)
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 autocd
BUFFER=$'/bin; /bin'
expected_region_highlight=(
'1 4 autodirectory' # /bin (in middle)
'5 5 commandseparator' # ;
'7 10 autodirectory' # /bin (at end)
)

View File

@ -0,0 +1,35 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'/bin/s'
expected_region_highlight=(
'1 6 path_prefix' # /bin/s
)

View File

@ -0,0 +1,35 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'/bin/sh'
expected_region_highlight=(
'1 7 command' # /bin/sh
)

View File

@ -0,0 +1,35 @@
# -------------------------------------------------------------------------------------------------
# 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
# -------------------------------------------------------------------------------------------------
alias foo="echo hello world"
BUFFER="foo"
expected_region_highlight+=(
"1 3 alias" # foo
)

View File

@ -0,0 +1,41 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2021 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
# -------------------------------------------------------------------------------------------------
# Have to use cat here as it must be a command that exists.
# Otherwise, the test would fail with the first token being recognized
# as an "unknown-token".
alias ]=cat
BUFFER='] /'
expected_region_highlight=(
'1 1 alias' # ]
'3 3 path' # /
)

View File

@ -0,0 +1,37 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 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 must be at least 4 characters to test the regression
# cf. 139ea2b189819c43cc251825981c116959b15cc3
alias foobar='echo "$(echo foobar)"'
BUFFER='foobar'
expected_region_highlight=(
"1 6 alias" # foobar
)

View File

@ -27,11 +27,11 @@
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# see alias-comment2.zsh
# see alias-comment2.zsh and comment-followed.zsh
setopt interactivecomments
alias x=$'# foo\npwd'
BUFFER='x'
expected_region_highlight=(
'1 1 alias "issue #616"' # x
'1 1 alias' # x
)

View File

@ -0,0 +1,36 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 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 ls='command ls'
BUFFER='ls'
expected_region_highlight=(
"1 2 alias" # ls
)

View File

@ -0,0 +1,36 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 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 ls=tmp tmp='command ls'
BUFFER='ls'
expected_region_highlight=(
"1 2 alias" # ls
)

View File

@ -0,0 +1,43 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 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 p='print -r --'
BUFFER=$'s=$(p foo)'
expected_region_highlight=(
'1 10 assign' # s=$(p foo)
'3 10 default' # $(p foo)
'3 10 command-substitution-unquoted' # $(p foo)
'3 4 command-substitution-delimiter-unquoted' # $(
'5 5 alias' # p
'7 9 default' # foo
'10 10 command-substitution-delimiter-unquoted' # )
)

View File

@ -28,12 +28,16 @@
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
function b() {} # beware of ALIAS_FUNC_DEF
alias a=b b=c c=b
BUFFER='a foo; :'
expected_region_highlight=(
'1 1 unknown-token' # a (invalid alias loop)
# An alias is ineligible for expansion whilst it's being expanded.
# Therefore, the "b" in the expansion of the alias "c" is not considered
# as an alias.
'1 1 alias' # a
'3 5 default' # foo
'6 6 commandseparator' # ;
'8 8 builtin' # :

View File

@ -0,0 +1,35 @@
# -------------------------------------------------------------------------------------------------
# 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
# -------------------------------------------------------------------------------------------------
alias ls="ls"
BUFFER="ls"
expected_region_highlight+=(
"1 2 alias" # ls
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 '$foo'='echo alias'
local foo; foo=(echo param)
BUFFER='$foo'
expected_region_highlight=(
'1 4 alias' # $foo
)

View File

@ -28,6 +28,7 @@
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# See also param-precommand-option-argument1.zsh
alias sudo_u='sudo -u'
sudo(){}

View File

@ -28,6 +28,7 @@
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# See also param-precommand-option-argument3.zsh
alias sudo_u='sudo -u'
sudo(){}

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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='a | a'
BUFFER='b | b'
expected_region_highlight=(
'1 1 alias' # b
'3 3 commandseparator' # |
'5 5 alias' # b
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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='a && a'
BUFFER='b && b'
expected_region_highlight=(
'1 1 alias' # b
'3 4 commandseparator' # &&
'6 6 alias' # b
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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='a; a'
BUFFER='b; b'
expected_region_highlight=(
'1 1 alias' # b
'2 2 commandseparator' # ;
'4 4 alias' # b
)

View File

@ -0,0 +1,42 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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='a $(a)'
BUFFER='b $(b)'
expected_region_highlight=(
'1 1 alias' # b
'3 6 default' # $(b)
'3 6 command-substitution-unquoted' # $(b)
'3 4 command-substitution-delimiter-unquoted' # $(
'5 5 alias' # b
'6 6 command-substitution-delimiter-unquoted' # )
)

View File

@ -0,0 +1,43 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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='a < <(a)'
BUFFER='b < <(b)'
expected_region_highlight=(
'1 1 alias' # b
'3 3 redirection' # <
'5 8 default' # <(b)
'5 8 process-substitution' # <(b)
'5 6 process-substitution-delimiter' # <(
'7 7 alias' # b
'8 8 process-substitution-delimiter' # )
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 cat='cat | cat'
BUFFER='cat'
expected_region_highlight=(
'1 3 alias' # cat
)

View File

@ -32,5 +32,5 @@ alias x=/
BUFFER=$'x'
expected_region_highlight=(
'1 1 unknown-token "issue #202"' # x (/)
'1 1 unknown-token' # x (/)
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 autocd
alias x=/
BUFFER=$'x'
expected_region_highlight=(
'1 1 alias' # x
)

View File

@ -32,7 +32,7 @@ BUFFER=$'{\nls\n} always { pwd }'
expected_region_highlight=(
'1 1 reserved-word' # {
'2 2 unknown-token' # \n
'2 2 commandseparator' # \n
'3 4 command' # ls
'5 5 commandseparator' # \n
'6 6 reserved-word' # }

View File

@ -0,0 +1,46 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 builtin' # :
'3 15 default' # $((ls); (ls))
'3 15 command-substitution-unquoted' # $((ls); (ls))
'3 4 command-substitution-delimiter-unquoted' # $(
'5 5 reserved-word' # (
'6 7 command' # ls
'8 8 reserved-word' # )
'9 9 commandseparator' # ;
'11 11 reserved-word' # (
'12 13 command' # ls
'14 14 reserved-word' # )
'15 15 command-substitution-delimiter-unquoted' # )
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(( 6 * 9 ))'
expected_region_highlight=(
'1 1 builtin' # :
'3 14 default' # $(( 6 * 9 ))
'3 14 arithmetic-expansion' # $(( 6 * 9 ))
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': "$(( 6 * 9 ))"'
expected_region_highlight=(
'1 1 builtin' # :
'3 16 default' # "$(( 6 * 9 ))"
'3 16 double-quoted-argument' # "$(( 6 * 9 ))"
'4 15 arithmetic-expansion' # $(( 6 * 9 ))
)

View File

@ -0,0 +1,42 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 2) + 2 ))'
expected_region_highlight=(
'1 1 builtin' # :
'3 22 default' # $(( $(echo 2) + 2 ))
'3 22 arithmetic-expansion' # $(( $(echo 2) + 2 ))
'7 15 command-substitution-quoted' # $(echo 2)
'7 8 command-substitution-delimiter-quoted' # $(
'9 12 builtin' # echo
'14 14 default' # 2
'15 15 command-substitution-delimiter' # )
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(( ((42)) ))'
expected_region_highlight=(
'1 1 builtin' # :
'3 15 default' # $(( ((42)) ))
'3 15 arithmetic-expansion' # $(( ((42)) ))
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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"'
expected_region_highlight=(
'1 1 builtin' # :
'3 17 default' # "foo"$(())"bar"
'3 7 double-quoted-argument' # "foo"
'8 12 arithmetic-expansion' # $(())
'13 17 double-quoted-argument' # "bar"
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(( \!\! ))'
expected_region_highlight=(
'1 1 builtin' # :
'3 11 default' # $(( !! ))
'3 11 arithmetic-expansion' # $(( !! ))
'7 8 history-expansion "issue #713"' # !!
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(( 0 * 1\'\'000 ))'
expected_region_highlight=(
'1 1 builtin' # :
'3 19 default' # $(( 0 * 1\'\'000 ))
'3 19 arithmetic-expansion' # $(( 0 * 1\'\'000 ))
'12 12 unknown-token' # \'
'13 13 unknown-token' # \'
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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*$(( 42 * 1729 ))*bar'
expected_region_highlight=(
'1 1 builtin' # :
'3 26 default' # foo*$(( 42 * 1729 ))*bar
'6 6 globbing' # *
'7 22 arithmetic-expansion' # $(( 42 * 1729 ))
'23 23 globbing' # *
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(( $(( 1 + 2 )) * 3 ))'
expected_region_highlight=(
'1 1 builtin' # :
'3 25 default' # $(( $(( 1 + 2 )) * 3 ))
'3 25 arithmetic-expansion' # $(( $(( 1 + 2 )) * 3 ))
'7 18 arithmetic-expansion' # $(( 1 + 2 ))
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': "$(( 1 + 1 ))"'
expected_region_highlight=(
'1 1 builtin' # :
'3 16 default' # "$(( 1 + 1 ))"
'3 16 double-quoted-argument' # "$(( 1 + 1 ))"
'4 15 arithmetic-expansion' # $(( 1 + 1 ))
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(( 1'
expected_region_highlight=(
'1 1 builtin' # :
'3 7 default' # $(( 1
'3 7 arithmetic-expansion' # $(( 1
)

View File

@ -0,0 +1,41 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(( 1729 )'
expected_region_highlight=(
'1 1 builtin' # :
'3 12 default' # $(( 1729 )
'3 12 arithmetic-expansion' # $(( 1729 )
)
if [[ ${(z):-'$('} == '$( ' ]]; then # ignore zsh 5.0.8 bug
expected_region_highlight[2]='3 13 default' # $(( 1729 )
fi

View File

@ -0,0 +1,45 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 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 )'
bar(){}
expected_region_highlight=(
'1 3 assign' # a=(
'3 3 reserved-word' # (
'5 7 default' # foo
'9 9 unknown-token' # |
# zsh reports a parse error at this point. Nevertheless, we test how we
# highlight the remainder of $BUFFER. Currently we recover by treating the pipe
# as a command separator. That's not the only reasonable behaviour, though; if
# we change the behaviour, we should adjust the following expectations accordingly.
'11 13 function' # bar
'15 15 unknown-token' # )
)

View File

@ -0,0 +1,41 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 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 3 assign' # a=(
'3 3 reserved-word' # (
'5 7 default' # foo
'9 9 unknown-token' # ; (not commandseparator; see highlighter source code)
'11 13 default' # bar
'15 15 assign' # )
'15 15 reserved-word' # )
)

View File

@ -0,0 +1,41 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 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 \n bar )'
expected_region_highlight=(
'1 3 assign' # a=(
'3 3 reserved-word' # (
'5 7 default' # foo
'9 9 commandseparator' # \n
'11 13 default' # bar
'15 15 assign' # )
'15 15 reserved-word' # )
)

View File

@ -31,7 +31,9 @@ BUFFER='a+=(lorem ipsum)'
expected_region_highlight=(
"1 4 assign" # a+=(
"4 4 reserved-word" # (
"5 9 default" # lorem
"11 15 default" # ipsum
"16 16 assign" # )
"16 16 reserved-word" # )
)

View File

@ -32,8 +32,10 @@ BUFFER='(A=(hello world))'
expected_region_highlight=(
"1 1 reserved-word" # (
"2 4 assign" # A=(
"4 4 reserved-word" # (
"5 9 default" # hello
"11 15 default" # world
"16 16 assign" # )
"16 16 reserved-word" # )
"17 17 reserved-word" # )
)

View File

@ -31,8 +31,10 @@ BUFFER='A=(hello world) ls'
expected_region_highlight=(
"1 3 assign" # A=(
"3 3 reserved-word" # (
"4 8 default" # hello
"10 14 default" # world
"15 15 assign" # )
"15 15 reserved-word" # )
"17 18 command" # ls
)

View File

@ -31,9 +31,11 @@ BUFFER='A=(hello world) b=42'
expected_region_highlight=(
"1 3 assign" # A=(
"3 3 reserved-word" # (
"4 8 default" # hello
"10 14 default" # world
"15 15 assign" # )
"15 15 reserved-word" # )
"17 20 assign" # b=42
"19 20 default" # 42
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'x=y nosuchcommand'
expected_region_highlight=(
'1 3 assign' # x=y
'3 3 default' # y
'5 17 unknown-token' # nosuchcommand
)

View File

@ -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=$'x="$(ls x y z)"'
expected_region_highlight=(
'1 15 assign' # x="$(ls x y z)"
'3 15 default' # "$(ls x y z)"
'3 3 double-quoted-argument' # "
'15 15 double-quoted-argument' # "
'4 14 command-substitution-quoted' # $(ls x y z)
'4 5 command-substitution-delimiter-quoted' # $(
'6 7 command' # ls
'9 9 default' # x
'11 11 default' # y
'13 13 default' # z
'14 14 command-substitution-delimiter-quoted' # )
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'s="foo\'bar"'
expected_region_highlight=(
'1 11 assign' # s="foo'bar"
'3 11 default' # "foo'bar"
'3 11 double-quoted-argument' # "foo'bar"
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'s="foo \'\' bar"'
expected_region_highlight=(
'1 14 assign' # s="foo '' bar"
'3 14 default' # "foo '' bar"
'3 14 double-quoted-argument' # "foo '' bar"
)

View File

@ -33,8 +33,10 @@ expected_region_highlight=(
"1 3 assign" # A=1
"3 3 default" # 1
"5 7 assign" # b=(
"7 7 reserved-word" # (
"8 12 default" # "foo"
"8 12 double-quoted-argument" # "foo"
"14 16 default" # bar
"17 17 assign" # )
"17 17 reserved-word" # )
)

View File

@ -0,0 +1,40 @@
#!/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=$'foo=bar { :; }'
expected_region_highlight=(
'1 7 assign' # foo=bar
'5 7 default' # bar
'9 9 unknown-token' # {
'11 11 builtin' # :
'12 12 commandseparator' # ;
'14 14 reserved-word' # }
)

View File

@ -0,0 +1,40 @@
#!/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=$'foo=bar ( :; )'
expected_region_highlight=(
'1 7 assign' # foo=bar
'5 7 default' # bar
'9 9 unknown-token' # (
'11 11 builtin' # :
'12 12 commandseparator' # ;
'14 14 unknown-token' # )
)

View File

@ -0,0 +1,37 @@
#!/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=$'foo=bar (( foo ))'
expected_region_highlight=(
'1 7 assign' # foo=bar
'5 7 default' # bar
'9 17 unknown-token' # (( foo ))
)

View File

@ -0,0 +1,40 @@
#!/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=$'foo=bar [[ -n foo ]]'
expected_region_highlight=(
'1 7 assign' # foo=bar
'5 7 default' # bar
'9 10 unknown-token' # [[
'12 13 single-hyphen-option' # -n
'15 17 default' # foo
'19 20 reserved-word' # ]]
)

View File

@ -0,0 +1,38 @@
#!/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=$'foo=bar \! :'
expected_region_highlight=(
'1 7 assign' # foo=bar
'5 7 default' # bar
'9 9 unknown-token' # \!
'11 11 builtin' # :
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$'1="foo"'
expected_region_highlight=(
'1 7 assign' # 1="foo"
'3 7 default' # "foo"
'3 7 double-quoted-argument' # "foo"
)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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\\\nbar"baz"'
expected_region_highlight=(
'1 4 builtin' # echo
'6 18 default "issue #705"' # foo\\\nbar"baz"
'14 18 double-quoted-argument "issue #705"' # "baz"
)

View File

@ -0,0 +1,34 @@
# -------------------------------------------------------------------------------------------------
# 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=$'\\'
expected_region_highlight=(
'1 1 unknown-token' # \\
)

View File

@ -32,9 +32,11 @@ BUFFER=$'foo=(bar abaz) \! ls'
expected_region_highlight=(
'1 5 assign' # foo=(
'5 5 reserved-word' # (
'6 8 default' # bar
'10 13 default' # abaz
'14 14 assign' # )
'14 14 reserved-word' # )
'16 16 unknown-token' # \!
'18 19 command' # ls
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2022 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=42 }'
expected_region_highlight=(
'1 1 reserved-word' # {
'3 6 assign' # a=42
'5 6 default' # 42
'8 8 reserved word "issue #854"' # }
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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
# -------------------------------------------------------------------------------------------------
cdpath=( $PWD )
mkdir foo foo/bar
BUFFER="/foo"
expected_region_highlight=(
'1 4 unknown-token' # x (/)
)

View File

@ -0,0 +1,44 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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
# -------------------------------------------------------------------------------------------------
# Test elision of some, but not all of the words
# See issue #667 for the case of eliding all words
local -a x; x=(sudo "")
sudo(){}
BUFFER=$'$x -u phy1729 ls'
expected_region_highlight=(
'1 2 precommand' # $x
# The "" is elided. If it weren't elided, the «ls» would be highlighted as an ordinary argument.
'4 5 single-hyphen-option' # -u
'7 13 default' # phy1729
'15 16 command' # ls
)

View File

@ -28,11 +28,12 @@
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# see alias-comment1.zsh
setopt interactivecomments
BUFFER=$'# foo\ntrue'
expected_region_highlight=(
'1 5 comment' # # foo
'6 6 commandseparator "issue #501"' # \n
'6 6 commandseparator' # \n
'7 10 builtin' # true
)

View File

@ -0,0 +1,41 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 ]]'
expected_region_highlight=(
'1 2 reserved-word' # [[
'4 6 default' # foo
'8 9 default' # &&
'11 13 default' # bar
'15 16 default' # ||
'18 20 default' # baz
'22 23 reserved-word' # ]]
)

View File

@ -30,7 +30,7 @@
mkdir foo
touch foo/bar
BUFFER=": foo/bar $PWD/foo foo/b"
X_ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo $PWD/bar)
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($PWD/foo $PWD/bar)
expected_region_highlight=(
'1 1 builtin' # :

View File

@ -28,10 +28,12 @@
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$':;\n'
# Newline after semicolon isn't unknown-token
BUFFER=$':;\n:'
expected_region_highlight=(
'1 1 builtin' # :
'2 2 commandseparator' # ;
'3 3 issue-623 "issue #616"' # \n
'3 3 commandseparator' # \n
'4 4 builtin' # :
)

View File

@ -0,0 +1,36 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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'
expected_region_highlight=(
'1 1 builtin' # :
'3 5 path' # =ls
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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
# -------------------------------------------------------------------------------------------------
unsetopt equals
BUFFER=$': =nosuchcommand'
expected_region_highlight=(
'1 1 builtin' # :
'3 16 default' # =nosuchcommand
)

View File

@ -0,0 +1,36 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': =nosuchcommand'
expected_region_highlight=(
'1 1 builtin' # :
'3 16 unknown-token' # =nosuchcommand
)

View File

@ -0,0 +1,36 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': ='
expected_region_highlight=(
'1 1 builtin' # :
'3 3 default' # =
)

View File

@ -0,0 +1,40 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 2
BUFFER=$'echo foo>&2'
expected_region_highlight=(
'1 4 builtin' # echo
'6 8 default' # foo
'9 10 redirection' # >&
'11 11 numeric-fd' # 2 (not path)
)

View File

@ -0,0 +1,38 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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 -g foo=bar
BUFFER=$'foo foo'
expected_region_highlight=(
'1 3 global-alias' # foo
'5 7 global-alias' # foo
)

View File

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=': !!= "!!="'
expected_region_highlight=(
'1 1 builtin' # :
'3 4 history-expansion "issue #713"' # !!
'7 11 default' # "!!="
'7 11 double-quoted-argument' # "!!="
'8 9 history-expansion "issue #713' # !!
)

View File

@ -0,0 +1,49 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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=$': $(kill -9 $$) ${:-$(kill -9 $$)}'
expected_region_highlight=(
'1 1 builtin' # :
'3 15 default' # $(kill -9 $$)
'3 15 command-substitution-unquoted' # $(kill -9 $$)
'3 4 command-substitution-delimiter-unquoted' # $(
'5 8 builtin' # kill
'10 11 single-hyphen-option' # -9
'13 14 default' # $$
'15 15 command-substitution-delimiter-unquoted' # )
'17 34 default' # ${:-$(kill -9 $$)}
'21 33 command-substitution-unquoted' # $(kill -9 $$)
'21 22 command-substitution-delimiter-unquoted' # $(
'23 26 builtin' # kill
'28 29 single-hyphen-option' # -9
'31 32 default' # $$
'33 33 command-substitution-delimiter-unquoted' # )
)

View File

@ -0,0 +1,40 @@
#!/usr/bin/env zsh
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2020 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
# -------------------------------------------------------------------------------------------------
# We aren't testing how this is highlighted; we're testing that it's not
# evaluated. If it gets evaluated, the test suite will die.
BUFFER=$': /(e*exit 42*)'
expected_region_highlight=(
'1 1 builtin' # :
'3 15 default' # /(e*exit 42*)
'6 6 globbing' # *
'14 14 globbing' # *
)

View File

@ -32,8 +32,10 @@ BUFFER=$'foo=(\nbar) env'
expected_region_highlight=(
'1 5 assign' # foo=(
'5 5 reserved-word' # (
'6 6 commandseparator' # \n
'7 9 default' # bar
'10 10 assign' # )
'12 14 command' # env
'10 10 reserved-word' # )
'12 14 precommand' # env
)

View File

@ -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
# -------------------------------------------------------------------------------------------------
unsetopt multios
BUFFER=$'cat < *'
expected_region_highlight=(
'1 3 command' # cat
'5 5 redirection' # <
'7 7 default' # * - not globbing
)

Some files were not shown because too many files have changed in this diff Show More