Compare commits
213 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f8b1470314 | ||
|
ade4b28d2d | ||
|
8211a95421 | ||
|
d4df626c03 | ||
|
8f5d74d219 | ||
|
700c0e18fe | ||
|
a50647e77b | ||
|
b253a8b86a | ||
|
4dd4797ae0 | ||
|
5171ec524f | ||
|
ea3ae74164 | ||
|
41b8a74692 | ||
|
3a4b212c7d | ||
|
0582ea1910 | ||
|
e65ebf0466 | ||
|
06710f3780 | ||
|
343ec1061f | ||
|
16d818a21f | ||
|
f1b9fbbaf0 | ||
|
8d32609a7b | ||
|
f5d1be7ec2 | ||
|
415e762ab2 | ||
|
ccb1da4ae8 | ||
|
96eb2e31a1 | ||
|
291634ecfe | ||
|
96e6cbe22f | ||
|
2a30d4fb5a | ||
|
90fec4d658 | ||
|
f563780236 | ||
|
b8c93afd34 | ||
|
2aca4e2c02 | ||
|
7678a8a227 | ||
|
5d139fcd94 | ||
|
d1802e388e | ||
|
aecfd61bbd | ||
|
2904e0f986 | ||
|
d5d2f22013 | ||
|
8eaa41431d | ||
|
e4f24f8901 | ||
|
1000da306a | ||
|
b44964c545 | ||
|
f54d829f03 | ||
|
9e9885253a | ||
|
3e7745ef30 | ||
|
b0af27f25f | ||
|
bd9094cc61 | ||
|
c7229a000a | ||
|
f2726d0464 | ||
|
8184266338 | ||
|
83ac855ceb | ||
|
3f930fb0c1 | ||
|
5545fb9ab2 | ||
|
a6eb966d96 | ||
|
c67372e96c | ||
|
29ca0bc6c8 | ||
|
08839bbd87 | ||
|
e2dddb91c6 | ||
|
cfef4f3ae0 | ||
|
48dd47931a | ||
|
3d81c83132 | ||
|
3c5f63d959 | ||
|
5a44d9f32a | ||
|
ea7c165b59 | ||
|
90a92b2bb8 | ||
|
fdf23e06c7 | ||
|
10171731f3 | ||
|
dfc41123d7 | ||
|
d6defe715a | ||
|
3ff5bec82e | ||
|
c4bb260a30 | ||
|
9bdeb4aa4a | ||
|
63852df983 | ||
|
66021cf0f7 | ||
|
0f627fdf60 | ||
|
bdb4e8b70e | ||
|
e6eea1f9b7 | ||
|
99389327ae | ||
|
e165f18c75 | ||
|
d237a60c9b | ||
|
2e65bb6d7d | ||
|
61c1cfe99f | ||
|
ea2f1060f6 | ||
|
e79ce6afd0 | ||
|
fb69f4ca81 | ||
|
1024ae8177 | ||
|
5720d87052 | ||
|
2339ee33b9 | ||
|
61945185ff | ||
|
936bc251a8 | ||
|
c699ce9a26 | ||
|
6e1a221699 | ||
|
9ceb7c6e7c | ||
|
b454b596ed | ||
|
e815d4579b | ||
|
3174e375f4 | ||
|
f56e3fad23 | ||
|
62e2d05f91 | ||
|
2cc2583f8f | ||
|
e15781c900 | ||
|
20d250d618 | ||
|
c73153c6e8 | ||
|
63bcd85dfa | ||
|
4bbd2a3bc6 | ||
|
241d3a92e8 | ||
|
6243c99f41 | ||
|
8f7e9b2af4 | ||
|
f63f07417d | ||
|
2331072c06 | ||
|
9e036e0b0c | ||
|
74c7ffc9b5 | ||
|
8feb06a022 | ||
|
fdf682a2f9 | ||
|
f564d11a41 | ||
|
8072651b6c | ||
|
9931990b92 | ||
|
525ba90932 | ||
|
9134cdf8d6 | ||
|
e94dc89606 | ||
|
f996d83975 | ||
|
54e1828d5c | ||
|
c5878ae632 | ||
|
498cc7641f | ||
|
81267ca313 | ||
|
bfd44f5c3f | ||
|
3ca93f864f | ||
|
a4525a0826 | ||
|
e58e45273f | ||
|
37b6f5052f | ||
|
a3c1757e47 | ||
|
b00be5f741 | ||
|
b85e313bc9 | ||
|
41d90cb5ed | ||
|
34df84a7dd | ||
|
1a752da1c2 | ||
|
8e3578240c | ||
|
edfc7dfd9b | ||
|
9880276756 | ||
|
027f522300 | ||
|
619fcad067 | ||
|
932e29a0c7 | ||
|
ec04a20681 | ||
|
cb8d68d00a | ||
|
04dd78cb00 | ||
|
4eb8a19133 | ||
|
36a3c0f82c | ||
|
d65f4f8a35 | ||
|
e07c901dfd | ||
|
3cea1434ae | ||
|
73c89c69a2 | ||
|
7fd44bc429 | ||
|
ab88dfad27 | ||
|
2b3638a211 | ||
|
3414c7c0d2 | ||
|
4a043b4d15 | ||
|
dc70e89bfd | ||
|
f729726300 | ||
|
f490b7cb95 | ||
|
2f4f81cab7 | ||
|
3558306149 | ||
|
1a55dc8fc2 | ||
|
52ea5c686a | ||
|
dde84e1b25 | ||
|
0e51046b19 | ||
|
4e92449752 | ||
|
b73853dd96 | ||
|
4546756500 | ||
|
9d380805d7 | ||
|
deee22ed42 | ||
|
77c6bf2019 | ||
|
27e4789439 | ||
|
e2e97dde9c | ||
|
9bf06c5c2a | ||
|
dfb917020c | ||
|
9ed2a46ed2 | ||
|
1c6a6d92b0 | ||
|
6b0671b63e | ||
|
b3b6d7129f | ||
|
9cb7e9a837 | ||
|
cb166dcc77 | ||
|
5012d771f3 | ||
|
3a6f7e7bfe | ||
|
b1f36d9c5f | ||
|
08edf8db7f | ||
|
6629a1f432 | ||
|
521fedfdf5 | ||
|
1618848df6 | ||
|
c3293ba0d8 | ||
|
21cdd6bc5e | ||
|
f32d1704b1 | ||
|
86fe054005 | ||
|
533bfa0116 | ||
|
2d0dddf58b | ||
|
27fa4a6546 | ||
|
ae5ad09cf5 | ||
|
3ee5aa0e06 | ||
|
eb277cdcc6 | ||
|
71dc090d02 | ||
|
6a310ada5b | ||
|
c1d5790c57 | ||
|
e9b1ce1a36 | ||
|
68fbe1a449 | ||
|
f02c0bf980 | ||
|
1be58a6f45 | ||
|
c0ad50e645 | ||
|
8b2768ab40 | ||
|
6f1f595e3e | ||
|
de95d50bce | ||
|
83862c1abb | ||
|
b7592e581d | ||
|
926c36c1fb | ||
|
4952325051 | ||
|
d5a4a6e195 | ||
|
e209cbe61a |
15
.editorconfig
Normal file
15
.editorconfig
Normal 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
|
||||||
|
|
@ -35,7 +35,7 @@ env:
|
|||||||
- ZSH=4.3.12
|
- ZSH=4.3.12
|
||||||
- ZSH=4.3.11
|
- ZSH=4.3.11
|
||||||
|
|
||||||
script: docker run -v $PWD:/work -w /work zshusers/zsh:${ZSH} /bin/sh -c 'install_packages make procps && make test'
|
script: docker run -v $PWD:/work -w /work zshusers/zsh:${ZSH} /bin/sh -c 'install_packages make procps bsdmainutils && make test'
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
webhooks:
|
webhooks:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
|
Copyright (c) 2010-2020 zsh-syntax-highlighting contributors
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted
|
Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
@ -6,7 +6,7 @@ How to install
|
|||||||
* Arch Linux: [community/zsh-syntax-highlighting][arch-package] / [AUR/zsh-syntax-highlighting-git][AUR-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])
|
* 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])
|
* 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])
|
* FreeBSD: `pkg install zsh-syntax-highlighting` (port name: [`shells/zsh-syntax-highlighting`][freebsd-port])
|
||||||
* Gentoo: [mv overlay][gentoo-overlay]
|
* Gentoo: [mv overlay][gentoo-overlay]
|
||||||
* Mac OS X / Homebrew: [brew install zsh-syntax-highlighting][brew-package]
|
* 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])
|
* Ubuntu: `zsh-syntax-highlighting` package [in Xenial][ubuntu-package] (or in [OBS repository][obs-repository])
|
||||||
|
2
Makefile
2
Makefile
@ -41,7 +41,7 @@ test:
|
|||||||
for test in highlighters/*; do \
|
for test in highlighters/*; do \
|
||||||
if [ -d $$test/test-data ]; then \
|
if [ -d $$test/test-data ]; then \
|
||||||
echo "Running test $${test##*/}"; \
|
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 |= $$? )); \
|
: $$(( result |= $$? )); \
|
||||||
fi \
|
fi \
|
||||||
done; \
|
done; \
|
||||||
|
@ -27,6 +27,11 @@ Before: [![Screenshot #3.1](images/before3-smaller.png)](images/before3.png)
|
|||||||
<br/>
|
<br/>
|
||||||
After: [![Screenshot #3.2](images/after3-smaller.png)](images/after3.png)
|
After: [![Screenshot #3.2](images/after3-smaller.png)](images/after3.png)
|
||||||
|
|
||||||
|
Before: [![Screenshot #4.1](images/before4-smaller.png)](images/before4-smaller.png)
|
||||||
|
<br/>
|
||||||
|
After: [![Screenshot #4.2](images/after4-smaller.png)](images/after4-smaller.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
How to install
|
How to install
|
||||||
--------------
|
--------------
|
||||||
|
170
changelog.md
170
changelog.md
@ -1,3 +1,173 @@
|
|||||||
|
# Changes in HEAD
|
||||||
|
|
||||||
|
- 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 `: $((42))` being highlighted as a subshell.
|
||||||
|
[part of #607]
|
||||||
|
|
||||||
|
- Regress highlighting of `: $((ls); (ls))`: is a subshell, but will now be
|
||||||
|
incorrectly highlighted as an arithmetic expansion.
|
||||||
|
[#704]
|
||||||
|
|
||||||
|
- 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 `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]
|
||||||
|
|
||||||
|
|
||||||
|
# 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
|
# Changes in version 0.6.0
|
||||||
|
|
||||||
This is a stable release, featuring bugfixes and minor improvements.
|
This is a stable release, featuring bugfixes and minor improvements.
|
||||||
|
@ -18,6 +18,23 @@ Syntax highlighting is done by pluggable highlighters:
|
|||||||
[6]: highlighters/line.md
|
[6]: 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 comand lines (for example, with the [`fned`][fned] utility
|
||||||
|
function). Example:
|
||||||
|
|
||||||
|
[fned]: http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#index-zed
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
ZSH_HIGHLIGHT_MAXLENGTH=512
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
How to activate highlighters
|
How to activate highlighters
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
@ -104,7 +121,7 @@ To create your own `acme` highlighter:
|
|||||||
`_zsh_highlight_highlighter_acme_paint` respectively.
|
`_zsh_highlight_highlighter_acme_paint` respectively.
|
||||||
|
|
||||||
These names are still supported for backwards compatibility;
|
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`:
|
* Activate your highlighter in `~/.zshrc`:
|
||||||
|
|
||||||
|
@ -20,12 +20,14 @@ This highlighter defines the following styles:
|
|||||||
* `reserved-word` - shell reserved words (`if`, `for`)
|
* `reserved-word` - shell reserved words (`if`, `for`)
|
||||||
* `alias` - aliases
|
* `alias` - aliases
|
||||||
* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
|
* `suffix-alias` - suffix aliases (requires zsh 5.1.1 or newer)
|
||||||
|
* `global-alias` - global aliases
|
||||||
* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
|
* `builtin` - shell builtin commands (`shift`, `pwd`, `zstyle`)
|
||||||
* `function` - function names
|
* `function` - function names
|
||||||
* `command` - command names
|
* `command` - command names
|
||||||
* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
|
* `precommand` - precommand modifiers (e.g., `noglob`, `builtin`)
|
||||||
* `commandseparator` - command separation tokens (`;`, `&&`)
|
* `commandseparator` - command separation tokens (`;`, `&&`)
|
||||||
* `hashed-command` - hashed commands
|
* `hashed-command` - hashed commands
|
||||||
|
* `autodirectory` - a directory name in command position when the `AUTO_CD` option is set
|
||||||
* `path` - existing filenames
|
* `path` - existing filenames
|
||||||
* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
|
* `path_pathseparator` - path separators in filenames (`/`); if unset, `path` is used (default)
|
||||||
* `path_prefix` - prefixes of existing filenames
|
* `path_prefix` - prefixes of existing filenames
|
||||||
@ -58,7 +60,9 @@ This highlighter defines the following styles:
|
|||||||
* `assign` - parameter assignments (`x=foo` and `x=( )`)
|
* `assign` - parameter assignments (`x=foo` and `x=( )`)
|
||||||
* `redirection` - redirection operators (`<`, `>`, etc)
|
* `redirection` - redirection operators (`<`, `>`, etc)
|
||||||
* `comment` - comments, when `setopt INTERACTIVE_COMMENTS` is in effect (`echo # foo`)
|
* `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).
|
* `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
|
* `default` - everything else
|
||||||
|
|
||||||
@ -86,7 +90,6 @@ manual page][zshzle-Character-Highlighting].
|
|||||||
#### Parameters
|
#### Parameters
|
||||||
|
|
||||||
To avoid partial path lookups on a path, add the path to the `ZSH_HIGHLIGHT_DIRS_BLACKLIST` array.
|
To avoid partial path lookups on a path, add the path to the `ZSH_HIGHLIGHT_DIRS_BLACKLIST` array.
|
||||||
This interface is still experimental.
|
|
||||||
|
|
||||||
```zsh
|
```zsh
|
||||||
ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
|
ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
# Copyright (c) 2010-2018 zsh-syntax-highlighting contributors
|
# Copyright (c) 2010-2020 zsh-syntax-highlighting contributors
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
@ -33,8 +33,10 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
|
: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
|
: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
|
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[global-alias]:=fg=cyan}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[autodirectory]:=fg=green,underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
|
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
|
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
|
||||||
@ -56,9 +58,10 @@
|
|||||||
: ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan}
|
: ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
|
: ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[redirection]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[redirection]:=fg=yellow}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
|
: ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[named-fd]:=none}
|
: ${ZSH_HIGHLIGHT_STYLES[named-fd]:=none}
|
||||||
|
: ${ZSH_HIGHLIGHT_STYLES[numeric-fd]:=none}
|
||||||
: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
|
: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
|
||||||
|
|
||||||
# Whether the highlighter should be called or not.
|
# Whether the highlighter should be called or not.
|
||||||
@ -77,6 +80,16 @@ _zsh_highlight_main_add_region_highlight() {
|
|||||||
[[ $1 == unknown-token ]] && alias_style=unknown-token
|
[[ $1 == unknown-token ]] && alias_style=unknown-token
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
if (( in_param )); then
|
||||||
|
if [[ $1 == unknown-token ]]; then
|
||||||
|
param_style=unknown-token
|
||||||
|
fi
|
||||||
|
if [[ -n $param_style ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
param_style=$1
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
# The calculation was relative to $buf but region_highlight is relative to $BUFFER.
|
# The calculation was relative to $buf but region_highlight is relative to $BUFFER.
|
||||||
(( start += buf_offset ))
|
(( start += buf_offset ))
|
||||||
@ -95,13 +108,19 @@ _zsh_highlight_main_calculate_fallback() {
|
|||||||
local -A fallback_of; fallback_of=(
|
local -A fallback_of; fallback_of=(
|
||||||
alias arg0
|
alias arg0
|
||||||
suffix-alias arg0
|
suffix-alias arg0
|
||||||
|
global-alias dollar-double-quoted-argument
|
||||||
builtin arg0
|
builtin arg0
|
||||||
function arg0
|
function arg0
|
||||||
command arg0
|
command arg0
|
||||||
precommand arg0
|
precommand arg0
|
||||||
hashed-command arg0
|
hashed-command arg0
|
||||||
|
autodirectory arg0
|
||||||
arg0_\* arg0
|
arg0_\* arg0
|
||||||
|
|
||||||
|
# TODO: Maybe these? —
|
||||||
|
# named-fd file-descriptor
|
||||||
|
# numeric-fd file-descriptor
|
||||||
|
|
||||||
path_prefix path
|
path_prefix path
|
||||||
# The path separator fallback won't ever be used, due to the optimisation
|
# The path separator fallback won't ever be used, due to the optimisation
|
||||||
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
# in _zsh_highlight_main_highlighter_highlight_path_separators().
|
||||||
@ -163,7 +182,9 @@ _zsh_highlight_main__type() {
|
|||||||
if (( $+aliases[(e)$1] )); then
|
if (( $+aliases[(e)$1] )); then
|
||||||
may_cache=0
|
may_cache=0
|
||||||
fi
|
fi
|
||||||
if (( $+aliases[(e)$1] )) && (( aliases_allowed )); then
|
if (( ${+galiases[(e)$1]} )) && (( aliases_allowed )); then
|
||||||
|
REPLY='global alias'
|
||||||
|
elif (( $+aliases[(e)$1] )) && (( aliases_allowed )); then
|
||||||
REPLY=alias
|
REPLY=alias
|
||||||
elif [[ $1 == *.* && -n ${1%.*} ]] && (( $+saliases[(e)${1##*.}] )); then
|
elif [[ $1 == *.* && -n ${1%.*} ]] && (( $+saliases[(e)${1##*.}] )); then
|
||||||
REPLY='suffix alias'
|
REPLY='suffix alias'
|
||||||
@ -188,7 +209,7 @@ _zsh_highlight_main__type() {
|
|||||||
elif { [[ $1 != */* ]] || is-at-least 5.3 } &&
|
elif { [[ $1 != */* ]] || is-at-least 5.3 } &&
|
||||||
# Add a subshell to avoid a zsh upstream bug; see issue #606.
|
# Add a subshell to avoid a zsh upstream bug; see issue #606.
|
||||||
# ### Remove the subshell when we stop supporting zsh 5.7.1 (I assume 5.8 will have the bugfix).
|
# ### Remove the subshell when we stop supporting zsh 5.7.1 (I assume 5.8 will have the bugfix).
|
||||||
! (builtin type -w -- $1) >/dev/null 2>&1; then
|
! (builtin type -w -- "$1") >/dev/null 2>&1; then
|
||||||
REPLY=none
|
REPLY=none
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -203,7 +224,7 @@ _zsh_highlight_main__type() {
|
|||||||
# starts with an arithmetic expression [«((…))» as the first thing inside
|
# starts with an arithmetic expression [«((…))» as the first thing inside
|
||||||
# «$(…)»], which is area that has had some parsing bugs before 5.6
|
# «$(…)»], which is area that has had some parsing bugs before 5.6
|
||||||
# (approximately).
|
# (approximately).
|
||||||
REPLY="${$(:; (( aliases_allowed )) || unalias -- $1 2>/dev/null; LC_ALL=C builtin type -w -- $1 2>/dev/null)##*: }"
|
REPLY="${$(:; (( aliases_allowed )) || unalias -- "$1" 2>/dev/null; LC_ALL=C builtin type -w -- "$1" 2>/dev/null)##*: }"
|
||||||
if [[ $REPLY == 'alias' ]]; then
|
if [[ $REPLY == 'alias' ]]; then
|
||||||
may_cache=0
|
may_cache=0
|
||||||
fi
|
fi
|
||||||
@ -252,6 +273,18 @@ _zsh_highlight_main__resolve_alias() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Return true iff $1 is a global alias
|
||||||
|
_zsh_highlight_main__is_global_alias() {
|
||||||
|
if zmodload -e zsh/parameter; then
|
||||||
|
(( ${+galiases[$arg]} ))
|
||||||
|
elif [[ $arg == '='* ]]; then
|
||||||
|
# avoid running into «alias -L '=foo'» erroring out with 'bad assignment'
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
alias -L -g -- "$1" >/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Check that the top of $braces_stack has the expected value. If it does, set
|
# Check that the top of $braces_stack has the expected value. If it does, set
|
||||||
# the style according to $2; otherwise, set style=unknown-token.
|
# the style according to $2; otherwise, set style=unknown-token.
|
||||||
#
|
#
|
||||||
@ -296,9 +329,13 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
# $flags_sans_argument is a set of letters, corresponding to the option letters
|
# $flags_sans_argument is a set of letters, corresponding to the option letters
|
||||||
# that wouldn't be followed by a colon in a getopts specification.
|
# that wouldn't be followed by a colon in a getopts specification.
|
||||||
local flags_sans_argument
|
local flags_sans_argument
|
||||||
# $precommand_options maps precommand name to values of $flags_with_argument and
|
# $flags_solo is a set of letters, corresponding to option letters that, if
|
||||||
# $flags_sans_argument for that precommand, joined by a colon. (The value is NOT
|
# present, mean the precommand will not be acting as a precommand, i.e., will
|
||||||
# a getopt(3) spec, although it resembles one.)
|
# not be followed by a :start: word.
|
||||||
|
local flags_solo
|
||||||
|
# $precommand_options maps precommand name to values of $flags_with_argument,
|
||||||
|
# $flags_sans_argument, and flags_solo for that precommand, joined by a
|
||||||
|
# colon. (The value is NOT a getopt(3) spec, although it resembles one.)
|
||||||
#
|
#
|
||||||
# Currently, setting $flags_sans_argument is only important for commands that
|
# Currently, setting $flags_sans_argument is only important for commands that
|
||||||
# have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
|
# have a non-empty $flags_with_argument; see test-data/precommand4.zsh.
|
||||||
@ -309,20 +346,37 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
'builtin' ''
|
'builtin' ''
|
||||||
'command' :pvV
|
'command' :pvV
|
||||||
'exec' a:cl
|
'exec' a:cl
|
||||||
'nocorrect' ''
|
|
||||||
'noglob' ''
|
'noglob' ''
|
||||||
'time' ''
|
# 'time' and 'nocorrect' shouldn't be added here; they're reserved words, not precommands.
|
||||||
|
|
||||||
'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
|
'doas' aCu:Lns # as of OpenBSD's doas(1) dated September 4, 2016
|
||||||
'nice' n: # as of current POSIX spec
|
'nice' n: # as of current POSIX spec
|
||||||
'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
|
'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags
|
||||||
'sudo' Cgprtu:AEHKPSVbhiklnsv # as of sudo 1.8.21p2
|
# Not listed: -h, which has two different meanings.
|
||||||
|
'sudo' Cgprtu:AEHPSbilns:eKkVv # as of sudo 1.8.21p2
|
||||||
'stdbuf' ioe:
|
'stdbuf' ioe:
|
||||||
'eatmydata' ''
|
'eatmydata' ''
|
||||||
'catchsegv' ''
|
'catchsegv' ''
|
||||||
'nohup' ''
|
'nohup' ''
|
||||||
'setsid' :wc
|
'setsid' :wc
|
||||||
|
'env' u:i
|
||||||
|
'ionice' cn:t:pPu # util-linux 2.33.1-0.1
|
||||||
|
'strace' IbeaosXPpEuOS:ACdfhikqrtTvVxyDc # strace 4.26-0.2
|
||||||
|
|
||||||
|
# As of OpenSSH 8.1p1
|
||||||
|
'ssh-agent' aEPt:csDd:k
|
||||||
|
# suckless-tools v44
|
||||||
|
# Argumentless flags that can't be followed by a command: -v
|
||||||
|
'tabbed' gnprtTuU:cdfhs
|
||||||
|
|
||||||
|
# moreutils 0.62-1
|
||||||
|
'chronic' :ev
|
||||||
|
'ifne' :n
|
||||||
|
|
||||||
)
|
)
|
||||||
|
# Commands that would need to skip one positional argument:
|
||||||
|
# flock
|
||||||
|
# ssh
|
||||||
|
|
||||||
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
|
if [[ $zsyh_user_options[ignorebraces] == on || ${zsyh_user_options[ignoreclosebraces]:-off} == on ]]; then
|
||||||
local right_brace_is_recognised_everywhere=false
|
local right_brace_is_recognised_everywhere=false
|
||||||
@ -336,6 +390,7 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
|
|
||||||
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR=(
|
||||||
'|' '||' ';' '&' '&&'
|
'|' '||' ';' '&' '&&'
|
||||||
|
$'\n' # ${(z)} returns ';' but we convert it to $'\n'
|
||||||
'|&'
|
'|&'
|
||||||
'&!' '&|'
|
'&!' '&|'
|
||||||
# ### 'case' syntax, but followed by a pattern, not by a command
|
# ### 'case' syntax, but followed by a pattern, not by a command
|
||||||
@ -379,6 +434,59 @@ _zsh_highlight_highlighter_main_paint()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Try to expand $1, if it's possible to do so safely.
|
||||||
|
#
|
||||||
|
# Uses two parameters from the caller: $parameter_name_pattern and $res.
|
||||||
|
#
|
||||||
|
# If expansion was done, set $reply to the expansion and return true.
|
||||||
|
# Otherwise, return false.
|
||||||
|
_zsh_highlight_main_highlighter__try_expand_parameter()
|
||||||
|
{
|
||||||
|
local arg="$1"
|
||||||
|
unset reply
|
||||||
|
{
|
||||||
|
# ### For now, expand just '$foo' or '${foo}', possibly with braces, but with
|
||||||
|
# ### no other features of the parameter expansion syntax. (No ${(x)foo},
|
||||||
|
# ### no ${foo[x]}, no ${foo:-x}.)
|
||||||
|
{
|
||||||
|
local -a match mbegin mend
|
||||||
|
local MATCH; integer MBEGIN MEND
|
||||||
|
local parameter_name
|
||||||
|
local -a words
|
||||||
|
if [[ $arg[1] != '$' ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
|
||||||
|
parameter_name=${${arg:2}%?}
|
||||||
|
else
|
||||||
|
parameter_name=${arg:1}
|
||||||
|
fi
|
||||||
|
if [[ $res == none ]] &&
|
||||||
|
[[ ${parameter_name} =~ ^${~parameter_name_pattern}$ ]] &&
|
||||||
|
[[ ${(tP)MATCH} != *special* ]]
|
||||||
|
then
|
||||||
|
# Set $arg and update $res.
|
||||||
|
case ${(tP)MATCH} in
|
||||||
|
(*array*|*assoc*)
|
||||||
|
words=( ${(P)MATCH} )
|
||||||
|
;;
|
||||||
|
("")
|
||||||
|
# not set
|
||||||
|
words=( )
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
# scalar, presumably
|
||||||
|
words=( ${(P)MATCH} )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
reply=( "${words[@]}" )
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# $1 is the offset of $4 from the parent buffer. Added to the returned highlights.
|
# $1 is the offset of $4 from the parent buffer. Added to the returned highlights.
|
||||||
# $2 is the initial braces_stack (for a closing paren).
|
# $2 is the initial braces_stack (for a closing paren).
|
||||||
# $3 is 1 if $4 contains the end of $BUFFER, else 0.
|
# $3 is 1 if $4 contains the end of $BUFFER, else 0.
|
||||||
@ -393,13 +501,13 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# alias_style is the style to apply to an alias once in_alias=0
|
# alias_style is the style to apply to an alias once in_alias=0
|
||||||
# Usually 'alias' but set to 'unknown-token' if any word expanded from
|
# Usually 'alias' but set to 'unknown-token' if any word expanded from
|
||||||
# the alias would be highlighted as unknown-token
|
# the alias would be highlighted as unknown-token
|
||||||
# last_alias is the last alias arg (lhs) expanded (if in an alias).
|
# param_style is analogous for parameter expansions
|
||||||
# This allows for expanding alias ls='ls -l' while avoiding loops.
|
local alias_style param_style last_arg arg buf=$4 highlight_glob=true saw_assignment=false style
|
||||||
local alias_style arg buf=$4 highlight_glob=true last_alias style
|
|
||||||
local in_array_assignment=false # true between 'a=(' and the matching ')'
|
local in_array_assignment=false # true between 'a=(' and the matching ')'
|
||||||
# in_alias is equal to the number of shifts needed until arg=args[1] pops an
|
# in_alias is equal to the number of shifts needed until arg=args[1] pops an
|
||||||
# arg from BUFFER and not added by an alias.
|
# arg from BUFFER and not added by an alias.
|
||||||
integer in_alias=0 len=$#buf
|
# in_param is analogous for parameter expansions
|
||||||
|
integer in_alias=0 in_param=0 len=$#buf
|
||||||
local -a match mbegin mend list_highlights
|
local -a match mbegin mend list_highlights
|
||||||
# seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a
|
# seen_alias is a map of aliases already seen to avoid loops like alias a=b b=a
|
||||||
local -A seen_alias
|
local -A seen_alias
|
||||||
@ -411,7 +519,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# "Q" for square
|
# "Q" for square
|
||||||
# "Y" for curly
|
# "Y" for curly
|
||||||
# "T" for [[ ]]
|
# "T" for [[ ]]
|
||||||
# "S" for $( )
|
# "S" for $( ), =( ), <( ), >( )
|
||||||
# "D" for do/done
|
# "D" for do/done
|
||||||
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
|
# "$" for 'end' (matches 'foreach' always; also used with cshjunkiequotes in repeat/while)
|
||||||
# "?" for 'if'/'fi'; also checked by 'elif'/'else'
|
# "?" for 'if'/'fi'; also checked by 'elif'/'else'
|
||||||
@ -429,18 +537,21 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# - :sudo_arg: The argument to a precommand's leading-dash option,
|
# - :sudo_arg: The argument to a precommand's leading-dash option,
|
||||||
# when given as a separate word; i.e., "foo" in "-u foo" (two
|
# when given as a separate word; i.e., "foo" in "-u foo" (two
|
||||||
# words) but not in "-ufoo" (one word).
|
# words) but not in "-ufoo" (one word).
|
||||||
|
# Note: :sudo_opt: and :sudo_arg: are used for any precommand
|
||||||
|
# declared in ${precommand_options}, not just for sudo(8).
|
||||||
|
# The naming is historical.
|
||||||
# - :regular: "Not a command word", and command delimiters are permitted.
|
# - :regular: "Not a command word", and command delimiters are permitted.
|
||||||
# Mainly used to detect premature termination of commands.
|
# Mainly used to detect premature termination of commands.
|
||||||
# - :always: The word 'always' in the «{ foo } always { bar }» syntax.
|
# - :always: The word 'always' in the «{ foo } always { bar }» syntax.
|
||||||
#
|
#
|
||||||
# When the kind of a word is not yet known, $this_word / $next_word may contain
|
# When the kind of a word is not yet known, $this_word / $next_word may contain
|
||||||
# multiple states. For example, after "sudo -i", the next word may be either
|
# multiple states. For example, after "sudo -i", the next word may be either
|
||||||
# another --flag or a command name, hence the state would include both :start:
|
# another --flag or a command name, hence the state would include both ':start:'
|
||||||
# and :sudo_opt:.
|
# and ':sudo_opt:'.
|
||||||
#
|
#
|
||||||
# The tokens are always added with both leading and trailing colons to serve as
|
# The tokens are always added with both leading and trailing colons to serve as
|
||||||
# word delimiters (an improvised array); [[ $x == *:foo:* ]] and x=${x//:foo:/}
|
# word delimiters (an improvised array); [[ $x == *':foo:'* ]] and x=${x//:foo:/}
|
||||||
# will DTRT regardless of how many elements or repetitions $x has..
|
# will DTRT regardless of how many elements or repetitions $x has.
|
||||||
#
|
#
|
||||||
# Handling of redirections: upon seeing a redirection token, we must stall
|
# Handling of redirections: upon seeing a redirection token, we must stall
|
||||||
# the current state --- that is, the value of $this_word --- for two iterations
|
# the current state --- that is, the value of $this_word --- for two iterations
|
||||||
@ -457,6 +568,13 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# $in_redirection. The value of $next_word from the iteration that processed
|
# $in_redirection. The value of $next_word from the iteration that processed
|
||||||
# the operator is discarded.
|
# the operator is discarded.
|
||||||
#
|
#
|
||||||
|
# $in_redirection is currently used for:
|
||||||
|
# - comments
|
||||||
|
# - aliases
|
||||||
|
# - redirections
|
||||||
|
# - parameter elision in command position
|
||||||
|
# - 'repeat' loops
|
||||||
|
#
|
||||||
local this_word next_word=':start::start_of_pipeline:'
|
local this_word next_word=':start::start_of_pipeline:'
|
||||||
integer in_redirection
|
integer in_redirection
|
||||||
# Processing buffer
|
# Processing buffer
|
||||||
@ -467,17 +585,33 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
else
|
else
|
||||||
args=(${(z)buf})
|
args=(${(z)buf})
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Special case: $(<*) isn't globbing.
|
||||||
|
if [[ $braces_stack == 'S' ]] && (( $+args[3] && ! $+args[4] )) && [[ $args[3] == $'\x29' ]] &&
|
||||||
|
[[ $args[1] == *'<'* ]] && _zsh_highlight_main__is_redirection $args[1]; then
|
||||||
|
highlight_glob=false
|
||||||
|
fi
|
||||||
|
|
||||||
while (( $#args )); do
|
while (( $#args )); do
|
||||||
|
last_arg=$arg
|
||||||
arg=$args[1]
|
arg=$args[1]
|
||||||
shift args
|
shift args
|
||||||
if (( in_alias )); then
|
if (( in_alias )); then
|
||||||
(( in_alias-- ))
|
(( in_alias-- ))
|
||||||
if (( in_alias == 0 )); then
|
if (( in_alias == 0 )); then
|
||||||
last_alias= seen_alias=()
|
seen_alias=()
|
||||||
# start_pos and end_pos are of the alias (previous $arg) here
|
# start_pos and end_pos are of the alias (previous $arg) here
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if (( in_param )); then
|
||||||
|
(( in_param-- ))
|
||||||
|
if (( in_param == 0 )); then
|
||||||
|
# start_pos and end_pos are of the '$foo' word (previous $arg) here
|
||||||
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
|
||||||
|
param_style=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Initialize this_word and next_word.
|
# Initialize this_word and next_word.
|
||||||
if (( in_redirection == 0 )); then
|
if (( in_redirection == 0 )); then
|
||||||
@ -493,6 +627,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# $style how to highlight $arg
|
# $style how to highlight $arg
|
||||||
# $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
|
# $in_array_assignment boolean flag for "between '(' and ')' of array assignment"
|
||||||
# $highlight_glob boolean flag for "'noglob' is in effect"
|
# $highlight_glob boolean flag for "'noglob' is in effect"
|
||||||
|
# $saw_assignment boolean flag for "was preceded by an assignment"
|
||||||
#
|
#
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
if [[ $this_word == *':start:'* ]]; then
|
if [[ $this_word == *':start:'* ]]; then
|
||||||
@ -502,14 +637,19 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( in_alias == 0 )); then
|
if (( in_alias == 0 && in_param == 0 )); then
|
||||||
# Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
|
# Compute the new $start_pos and $end_pos, skipping over whitespace in $buf.
|
||||||
[[ "$proc_buf" = (#b)(#s)(([ $'\t']|\\$'\n')#)* ]]
|
[[ "$proc_buf" = (#b)(#s)(([ $'\t']|[\\]$'\n')#)(?|)* ]]
|
||||||
# The first, outer parenthesis
|
# The first, outer parenthesis
|
||||||
integer offset="${#match[1]}"
|
integer offset="${#match[1]}"
|
||||||
(( start_pos = end_pos + offset ))
|
(( start_pos = end_pos + offset ))
|
||||||
(( end_pos = start_pos + $#arg ))
|
(( end_pos = start_pos + $#arg ))
|
||||||
|
|
||||||
|
# The zsh lexer considers ';' and newline to be the same token, so
|
||||||
|
# ${(z)} converts all newlines to semicolons. Convert them back here to
|
||||||
|
# make later processing simpler.
|
||||||
|
[[ $arg == ';' && ${match[3]} == $'\n' ]] && arg=$'\n'
|
||||||
|
|
||||||
# Compute the new $proc_buf. We advance it
|
# Compute the new $proc_buf. We advance it
|
||||||
# (chop off characters from the beginning)
|
# (chop off characters from the beginning)
|
||||||
# beyond what end_pos points to, by skipping
|
# beyond what end_pos points to, by skipping
|
||||||
@ -545,20 +685,19 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $this_word == *:start:* ]] && ! (( in_redirection )); then
|
if [[ $this_word == *':start:'* ]] && ! (( in_redirection )); then
|
||||||
# Expand aliases.
|
# Expand aliases.
|
||||||
_zsh_highlight_main__type "$arg"
|
# An alias is ineligible for expansion while it's being expanded (see #652/#653).
|
||||||
|
_zsh_highlight_main__type "$arg" "$(( ! ${+seen_alias[$arg]} ))"
|
||||||
local res="$REPLY"
|
local res="$REPLY"
|
||||||
if [[ $res == "alias" ]] && [[ $last_alias != $arg ]]; then
|
if [[ $res == "alias" ]]; then
|
||||||
# Avoid looping forever on alias a=b b=c c=b, but allow alias foo='foo bar'
|
# Mark insane aliases as unknown-token (cf. #263).
|
||||||
# Also mark insane aliases as unknown-token (cf. #263).
|
if [[ $arg == ?*=* ]]; then
|
||||||
if (( $+seen_alias[$arg] )) || [[ $arg == ?*=* ]]; then
|
|
||||||
(( in_alias == 0 )) && in_alias=1
|
(( in_alias == 0 )) && in_alias=1
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
seen_alias[$arg]=1
|
seen_alias[$arg]=1
|
||||||
last_alias=$arg
|
|
||||||
_zsh_highlight_main__resolve_alias $arg
|
_zsh_highlight_main__resolve_alias $arg
|
||||||
local -a alias_args
|
local -a alias_args
|
||||||
# Elision is desired in case alias x=''
|
# Elision is desired in case alias x=''
|
||||||
@ -581,8 +720,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
_zsh_highlight_main_highlighter_expand_path $arg
|
_zsh_highlight_main_highlighter_expand_path $arg
|
||||||
arg=$REPLY
|
_zsh_highlight_main__type "$REPLY" 0
|
||||||
_zsh_highlight_main__type "$arg" 0
|
|
||||||
res="$REPLY"
|
res="$REPLY"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -590,7 +728,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
# Analyse the current word.
|
# Analyse the current word.
|
||||||
if _zsh_highlight_main__is_redirection $arg ; then
|
if _zsh_highlight_main__is_redirection $arg ; then
|
||||||
if (( in_redirection == 1 )); then
|
if (( in_redirection == 1 )); then
|
||||||
# The condition excludes the case that BUFFER='{foo}>&2' and we're on the '>&'.
|
# Two consecuive redirection operators is an error.
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
||||||
else
|
else
|
||||||
in_redirection=2
|
in_redirection=2
|
||||||
@ -605,55 +743,50 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Expand parameters.
|
# Expand parameters.
|
||||||
#
|
if (( ! in_param )) && _zsh_highlight_main_highlighter__try_expand_parameter "$arg"; then
|
||||||
# ### For now, expand just '$foo' or '${foo}', possibly with braces, but with
|
|
||||||
# ### no other features of the parameter expansion syntax. (No ${(x)foo},
|
|
||||||
# ### no ${foo[x]}, no ${foo:-x}.)
|
|
||||||
() {
|
|
||||||
# That's not entirely correct --- if the parameter's value happens to be a reserved
|
# That's not entirely correct --- if the parameter's value happens to be a reserved
|
||||||
# word, the parameter expansion will be highlighted as a reserved word --- but that
|
# word, the parameter expansion will be highlighted as a reserved word --- but that
|
||||||
# incorrectness is outweighed by the usability improvement of permitting the use of
|
# incorrectness is outweighed by the usability improvement of permitting the use of
|
||||||
# parameters that refer to commands, functions, and builtins.
|
# parameters that refer to commands, functions, and builtins.
|
||||||
local -a match mbegin mend
|
() {
|
||||||
local MATCH; integer MBEGIN MEND
|
local -a words; words=( "${reply[@]}" )
|
||||||
local parameter_name
|
if (( $#words == 0 )) && (( ! in_redirection )); then
|
||||||
if [[ $arg[1] == '$' ]] && [[ ${arg[2]} == '{' ]] && [[ ${arg[-1]} == '}' ]]; then
|
# Parameter elision is happening
|
||||||
parameter_name=${${arg:2}%?}
|
(( ++in_redirection ))
|
||||||
elif [[ $arg[1] == '$' ]]; then
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos comment
|
||||||
parameter_name=${arg:1}
|
continue
|
||||||
fi
|
else
|
||||||
if [[ $res == none ]] && zmodload -e zsh/parameter &&
|
(( in_param = 1 + $#words ))
|
||||||
[[ ${parameter_name} =~ ^${~parameter_name_pattern}$ ]] &&
|
args=( $words $args )
|
||||||
(( ${+parameters[(e)${MATCH}]} )) && [[ ${parameters[(e)$MATCH]} != *special* ]]
|
arg=$args[1]
|
||||||
then
|
|
||||||
# Set $arg.
|
|
||||||
case ${(tP)MATCH} in
|
|
||||||
(*array*|*assoc*)
|
|
||||||
local -a words; words=( ${(P)MATCH} )
|
|
||||||
arg=${words[1]}
|
|
||||||
;;
|
|
||||||
(*)
|
|
||||||
# scalar, presumably
|
|
||||||
arg=${(P)MATCH}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
_zsh_highlight_main__type "$arg" 0
|
_zsh_highlight_main__type "$arg" 0
|
||||||
res=$REPLY
|
res=$REPLY
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Parse the sudo command line
|
# Parse the sudo command line
|
||||||
if (( ! in_redirection )); then
|
if (( ! in_redirection )); then
|
||||||
if [[ $this_word == *':sudo_opt:'* ]]; then
|
if [[ $this_word == *':sudo_opt:'* ]]; then
|
||||||
if [[ -n $flags_with_argument ]] &&
|
if [[ -n $flags_with_argument ]] &&
|
||||||
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]] ||
|
{
|
||||||
[[ $arg == '-'[$flags_with_argument] ]] }; then
|
# Trenary
|
||||||
|
if [[ -n $flags_sans_argument ]]
|
||||||
|
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument] ]]
|
||||||
|
else [[ $arg == '-'[$flags_with_argument] ]]
|
||||||
|
fi
|
||||||
|
} then
|
||||||
# Flag that requires an argument
|
# Flag that requires an argument
|
||||||
this_word=${this_word//:start:/}
|
this_word=${this_word//:start:/}
|
||||||
next_word=':sudo_arg:'
|
next_word=':sudo_arg:'
|
||||||
elif [[ -n $flags_with_argument ]] &&
|
elif [[ -n $flags_with_argument ]] &&
|
||||||
{ [[ -n $flags_sans_argument ]] && [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]] ||
|
{
|
||||||
[[ $arg == '-'[$flags_with_argument]* ]] }; then
|
# Trenary
|
||||||
|
if [[ -n $flags_sans_argument ]]
|
||||||
|
then [[ $arg == '-'[$flags_sans_argument]#[$flags_with_argument]* ]]
|
||||||
|
else [[ $arg == '-'[$flags_with_argument]* ]]
|
||||||
|
fi
|
||||||
|
} then
|
||||||
# Argument attached in the same word
|
# Argument attached in the same word
|
||||||
this_word=${this_word//:start:/}
|
this_word=${this_word//:start:/}
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
@ -661,16 +794,31 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
elif [[ -n $flags_sans_argument ]] &&
|
elif [[ -n $flags_sans_argument ]] &&
|
||||||
[[ $arg == '-'[$flags_sans_argument]# ]]; then
|
[[ $arg == '-'[$flags_sans_argument]# ]]; then
|
||||||
# Flag that requires no argument
|
# Flag that requires no argument
|
||||||
this_word=:sudo_opt:
|
this_word=':sudo_opt:'
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
next_word+=':sudo_opt:'
|
next_word+=':sudo_opt:'
|
||||||
|
elif [[ -n $flags_solo ]] &&
|
||||||
|
{
|
||||||
|
# Trenary
|
||||||
|
if [[ -n $flags_sans_argument ]]
|
||||||
|
then [[ $arg == '-'[$flags_sans_argument]#[$flags_solo]* ]]
|
||||||
|
else [[ $arg == '-'[$flags_solo]* ]]
|
||||||
|
fi
|
||||||
|
} then
|
||||||
|
# Solo flags
|
||||||
|
this_word=':sudo_opt:'
|
||||||
|
next_word=':regular:' # no :start:, nor :sudo_opt: since we don't know whether the solo flag takes an argument or not
|
||||||
elif [[ $arg == '-'* ]]; then
|
elif [[ $arg == '-'* ]]; then
|
||||||
# Unknown flag
|
# Unknown flag. We don't know whether it takes an argument or not,
|
||||||
this_word=:sudo_opt:
|
# so modify $next_word as we do for flags that require no argument.
|
||||||
|
# With that behaviour, if the flag in fact takes no argument we'll
|
||||||
|
# highlight the inner command word correctly, and if it does take an
|
||||||
|
# argument we'll highlight the command word correctly if the argument
|
||||||
|
# was given in the same shell word as the flag (as in '-uphy1729' or
|
||||||
|
# '--user=phy1729' without spaces).
|
||||||
|
this_word=':sudo_opt:'
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
next_word+=':sudo_opt:'
|
next_word+=':sudo_opt:'
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos unknown-token
|
|
||||||
continue
|
|
||||||
else
|
else
|
||||||
# Not an option flag; nothing to do. (If the command line is
|
# Not an option flag; nothing to do. (If the command line is
|
||||||
# syntactically valid, ${this_word//:sudo_opt:/} should be
|
# syntactically valid, ${this_word//:sudo_opt:/} should be
|
||||||
@ -684,45 +832,90 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# The Great Fork: is this a command word? Is this a non-command word?
|
# The Great Fork: is this a command word? Is this a non-command word?
|
||||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]]; then
|
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR:#"$arg"} ]] &&
|
||||||
|
[[ $braces_stack != *T* || $arg != ('||'|'&&') ]]; then
|
||||||
|
|
||||||
|
# First, determine the style of the command separator itself.
|
||||||
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
|
if _zsh_highlight_main__stack_pop T || _zsh_highlight_main__stack_pop Q; then
|
||||||
# Missing closing square bracket(s)
|
# Missing closing square bracket(s)
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
|
elif $in_array_assignment; then
|
||||||
|
case $arg in
|
||||||
|
# Literal newlines are just fine.
|
||||||
|
($'\n') style=commandseparator;;
|
||||||
|
# Semicolons are parsed the same way as literal newlines. Nevertheless,
|
||||||
|
# highlight them as errors since they're probably unintended. Compare
|
||||||
|
# issue #691.
|
||||||
|
(';') style=unknown-token;;
|
||||||
|
# Other command separators aren't allowed.
|
||||||
|
(*) style=unknown-token;;
|
||||||
|
esac
|
||||||
elif [[ $this_word == *':regular:'* ]]; then
|
elif [[ $this_word == *':regular:'* ]]; then
|
||||||
# This highlights empty commands (semicolon follows nothing) as an error.
|
style=commandseparator
|
||||||
# Zsh accepts them, though.
|
elif [[ $this_word == *':start:'* ]] && [[ $arg == $'\n' ]]; then
|
||||||
|
style=commandseparator
|
||||||
|
elif [[ $this_word == *':start:'* ]] && [[ $arg == ';' ]] && (( in_alias )); then
|
||||||
style=commandseparator
|
style=commandseparator
|
||||||
else
|
else
|
||||||
|
# Empty commands (semicolon follows nothing) are valid syntax.
|
||||||
|
# However, in interactive use they are likely to be erroneous;
|
||||||
|
# therefore, we highlight them as errors.
|
||||||
|
#
|
||||||
|
# Alias definitions are exempted from this check to allow multiline aliases
|
||||||
|
# with explicit (redundant) semicolons: «alias foo=$'bar;\nbaz'» (issue #677).
|
||||||
|
#
|
||||||
|
# See also #691 about possibly changing the style used here.
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
fi
|
fi
|
||||||
if [[ $arg == ';' ]] && $in_array_assignment; then
|
|
||||||
|
# Second, determine the style of next_word.
|
||||||
|
if [[ $arg == $'\n' ]] && $in_array_assignment; then
|
||||||
# literal newline inside an array assignment
|
# literal newline inside an array assignment
|
||||||
next_word=':regular:'
|
next_word=':regular:'
|
||||||
|
elif [[ $arg == ';' ]] && $in_array_assignment; then
|
||||||
|
# literal semicolon inside an array assignment
|
||||||
|
next_word=':regular:'
|
||||||
else
|
else
|
||||||
next_word=':start:'
|
next_word=':start:'
|
||||||
highlight_glob=true
|
highlight_glob=true
|
||||||
|
saw_assignment=false
|
||||||
if [[ $arg != '|' && $arg != '|&' ]]; then
|
if [[ $arg != '|' && $arg != '|&' ]]; then
|
||||||
next_word+=':start_of_pipeline:'
|
next_word+=':start_of_pipeline:'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
|
elif ! (( in_redirection)) && [[ $this_word == *':always:'* && $arg == 'always' ]]; then
|
||||||
# try-always construct
|
# try-always construct
|
||||||
style=reserved-word # de facto a reserved word, although not de jure
|
style=reserved-word # de facto a reserved word, although not de jure
|
||||||
next_word=':start:' # only left brace is allowed, apparently
|
highlight_glob=true
|
||||||
|
saw_assignment=false
|
||||||
|
next_word=':start::start_of_pipeline:' # only left brace is allowed, apparently
|
||||||
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
|
elif ! (( in_redirection)) && [[ $this_word == *':start:'* ]]; then # $arg is the command word
|
||||||
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
|
if (( ${+precommand_options[$arg]} )) && _zsh_highlight_main__is_runnable $arg; then
|
||||||
style=precommand
|
style=precommand
|
||||||
flags_with_argument=${precommand_options[$arg]%:*}
|
() {
|
||||||
flags_sans_argument=${precommand_options[$arg]#*:}
|
set -- "${(@s.:.)precommand_options[$arg]}"
|
||||||
|
flags_with_argument=$1
|
||||||
|
flags_sans_argument=$2
|
||||||
|
flags_solo=$3
|
||||||
|
}
|
||||||
next_word=${next_word//:regular:/}
|
next_word=${next_word//:regular:/}
|
||||||
next_word+=':sudo_opt:'
|
next_word+=':sudo_opt:'
|
||||||
next_word+=':start:'
|
next_word+=':start:'
|
||||||
|
if [[ $arg == 'exec' ]]; then
|
||||||
|
# To allow "exec 2>&1;" where there's no command word
|
||||||
|
next_word+=':regular:'
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
case $res in
|
case $res in
|
||||||
reserved) # reserved word
|
(reserved) # reserved word
|
||||||
style=reserved-word
|
style=reserved-word
|
||||||
# Match braces and handle special cases.
|
# Match braces and handle special cases.
|
||||||
case $arg in
|
case $arg in
|
||||||
|
(time|nocorrect)
|
||||||
|
next_word=${next_word//:regular:/}
|
||||||
|
next_word+=':start:'
|
||||||
|
;;
|
||||||
($'\x7b')
|
($'\x7b')
|
||||||
braces_stack='Y'"$braces_stack"
|
braces_stack='Y'"$braces_stack"
|
||||||
;;
|
;;
|
||||||
@ -791,18 +984,27 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
if $saw_assignment && [[ $style != unknown-token ]]; then
|
||||||
|
style=unknown-token
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
'suffix alias') style=suffix-alias;;
|
('suffix alias')
|
||||||
alias) :;;
|
style=suffix-alias
|
||||||
builtin) style=builtin
|
;;
|
||||||
|
('global alias')
|
||||||
|
style=global-alias
|
||||||
|
;;
|
||||||
|
(alias) :;;
|
||||||
|
(builtin) style=builtin
|
||||||
[[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack"
|
[[ $arg == $'\x5b' ]] && braces_stack='Q'"$braces_stack"
|
||||||
;;
|
;;
|
||||||
function) style=function;;
|
(function) style=function;;
|
||||||
command) style=command;;
|
(command) style=command;;
|
||||||
hashed) style=hashed-command;;
|
(hashed) style=hashed-command;;
|
||||||
none) if _zsh_highlight_main_highlighter_check_assign; then
|
(none) if (( ! in_param )) && _zsh_highlight_main_highlighter_check_assign; then
|
||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos assign
|
||||||
local i=$(( arg[(i)=] + 1 ))
|
local i=$(( arg[(i)=] + 1 ))
|
||||||
|
saw_assignment=true
|
||||||
if [[ $arg[i] == '(' ]]; then
|
if [[ $arg[i] == '(' ]]; then
|
||||||
in_array_assignment=true
|
in_array_assignment=true
|
||||||
else
|
else
|
||||||
@ -821,11 +1023,15 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
elif [[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
|
elif (( ! in_param )) &&
|
||||||
|
[[ $arg[0,1] = $histchars[0,1] ]] && (( $#arg[0,2] == 2 )); then
|
||||||
style=history-expansion
|
style=history-expansion
|
||||||
elif [[ $arg[0,1] == $histchars[2,2] ]]; then
|
elif (( ! in_param )) &&
|
||||||
|
[[ $arg[0,1] == $histchars[2,2] ]]; then
|
||||||
style=history-expansion
|
style=history-expansion
|
||||||
elif [[ $arg[1,2] == '((' ]]; then
|
elif (( ! in_param )) &&
|
||||||
|
! $saw_assignment &&
|
||||||
|
[[ $arg[1,2] == '((' ]]; then
|
||||||
# Arithmetic evaluation.
|
# Arithmetic evaluation.
|
||||||
#
|
#
|
||||||
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
|
# Note: prior to zsh-5.1.1-52-g4bed2cf (workers/36669), the ${(z)...}
|
||||||
@ -840,14 +1046,18 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
|
_zsh_highlight_main_add_region_highlight $((end_pos - 2)) $end_pos reserved-word
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
elif [[ $arg == '()' ]]; then
|
elif (( ! in_param )) &&
|
||||||
|
[[ $arg == '()' ]]; then
|
||||||
# anonymous function
|
# anonymous function
|
||||||
style=reserved-word
|
style=reserved-word
|
||||||
elif [[ $arg == $'\x28' ]]; then
|
elif (( ! in_param )) &&
|
||||||
|
! $saw_assignment &&
|
||||||
|
[[ $arg == $'\x28' ]]; then
|
||||||
# subshell
|
# subshell
|
||||||
style=reserved-word
|
style=reserved-word
|
||||||
braces_stack='R'"$braces_stack"
|
braces_stack='R'"$braces_stack"
|
||||||
elif [[ $arg == $'\x29' ]]; then
|
elif (( ! in_param )) &&
|
||||||
|
[[ $arg == $'\x29' ]]; then
|
||||||
# end of subshell or command substitution
|
# end of subshell or command substitution
|
||||||
if _zsh_highlight_main__stack_pop 'S'; then
|
if _zsh_highlight_main__stack_pop 'S'; then
|
||||||
REPLY=$start_pos
|
REPLY=$start_pos
|
||||||
@ -856,14 +1066,14 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
fi
|
fi
|
||||||
_zsh_highlight_main__stack_pop 'R' reserved-word
|
_zsh_highlight_main__stack_pop 'R' reserved-word
|
||||||
else
|
else
|
||||||
if _zsh_highlight_main_highlighter_check_path $arg; then
|
if _zsh_highlight_main_highlighter_check_path $arg 1; then
|
||||||
style=$REPLY
|
style=$REPLY
|
||||||
else
|
else
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
|
(*) _zsh_highlight_main_add_region_highlight $start_pos $end_pos arg0_$res
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -871,9 +1081,12 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
|
if [[ -n ${(M)ZSH_HIGHLIGHT_TOKENS_CONTROL_FLOW:#"$arg"} ]]; then
|
||||||
next_word=':start::start_of_pipeline:'
|
next_word=':start::start_of_pipeline:'
|
||||||
fi
|
fi
|
||||||
|
elif _zsh_highlight_main__is_global_alias "$arg"; then # $arg is a global alias that isn't in command position
|
||||||
|
style=global-alias
|
||||||
else # $arg is a non-command word
|
else # $arg is a non-command word
|
||||||
case $arg in
|
case $arg in
|
||||||
$'\x29') # subshell or end of array assignment
|
($'\x29')
|
||||||
|
# subshell or end of array assignment
|
||||||
if $in_array_assignment; then
|
if $in_array_assignment; then
|
||||||
style=assign
|
style=assign
|
||||||
in_array_assignment=false
|
in_array_assignment=false
|
||||||
@ -887,8 +1100,10 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
_zsh_highlight_main__stack_pop 'R' reserved-word
|
_zsh_highlight_main__stack_pop 'R' reserved-word
|
||||||
fi;;
|
fi
|
||||||
$'\x28\x29') # possibly a function definition
|
;;
|
||||||
|
($'\x28\x29')
|
||||||
|
# possibly a function definition
|
||||||
if (( in_redirection )) || $in_array_assignment; then
|
if (( in_redirection )) || $in_array_assignment; then
|
||||||
style=unknown-token
|
style=unknown-token
|
||||||
else
|
else
|
||||||
@ -899,7 +1114,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
style=reserved-word
|
style=reserved-word
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*) if false; then
|
(*) if false; then
|
||||||
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
|
elif [[ $arg = $'\x7d' ]] && $right_brace_is_recognised_everywhere; then
|
||||||
# Parsing rule: {
|
# Parsing rule: {
|
||||||
#
|
#
|
||||||
@ -929,6 +1144,7 @@ _zsh_highlight_main_highlighter_highlight_list()
|
|||||||
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
_zsh_highlight_main_add_region_highlight $start_pos $end_pos $style
|
||||||
done
|
done
|
||||||
(( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
(( in_alias == 1 )) && in_alias=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $alias_style
|
||||||
|
(( in_param == 1 )) && in_param=0 _zsh_highlight_main_add_region_highlight $start_pos $end_pos $param_style
|
||||||
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
|
[[ "$proc_buf" = (#b)(#s)(([[:space:]]|\\$'\n')#) ]]
|
||||||
REPLY=$(( end_pos + ${#match[1]} - 1 ))
|
REPLY=$(( end_pos + ${#match[1]} - 1 ))
|
||||||
reply=($list_highlights)
|
reply=($list_highlights)
|
||||||
@ -959,12 +1175,32 @@ _zsh_highlight_main_highlighter_highlight_path_separators()
|
|||||||
# Check if $1 is a path.
|
# Check if $1 is a path.
|
||||||
# If yes, return 0 and in $REPLY the style to use.
|
# If yes, return 0 and in $REPLY the style to use.
|
||||||
# Else, return non-zero (and the contents of $REPLY is undefined).
|
# Else, return non-zero (and the contents of $REPLY is undefined).
|
||||||
|
#
|
||||||
|
# $2 should be non-zero iff we're in command position.
|
||||||
_zsh_highlight_main_highlighter_check_path()
|
_zsh_highlight_main_highlighter_check_path()
|
||||||
{
|
{
|
||||||
_zsh_highlight_main_highlighter_expand_path "$1"
|
_zsh_highlight_main_highlighter_expand_path "$1"
|
||||||
local expanded_path="$REPLY" tmp_path
|
local expanded_path="$REPLY" tmp_path
|
||||||
|
integer in_command_position=$2
|
||||||
|
|
||||||
|
if [[ $zsyh_user_options[autocd] == on ]]; then
|
||||||
|
integer autocd=1
|
||||||
|
else
|
||||||
|
integer autocd=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( in_command_position )); then
|
||||||
|
# ### Currently, this value is never returned: either it's overwritten
|
||||||
|
# ### below, or the return code is non-zero
|
||||||
|
REPLY=arg0
|
||||||
|
else
|
||||||
REPLY=path
|
REPLY=path
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${1[1]} == '=' && $1 == ??* && ${1[2]} != $'\x28' && $zsyh_user_options[equals] == 'on' && $expanded_path[1] != '/' ]]; then
|
||||||
|
REPLY=unknown-token # will error out if executed
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
[[ -z $expanded_path ]] && return 1
|
[[ -z $expanded_path ]] && return 1
|
||||||
|
|
||||||
@ -981,24 +1217,56 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
tmp_path=$tmp_path:h
|
tmp_path=$tmp_path:h
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ -L $expanded_path ]] && return 0
|
if (( in_command_position )); then
|
||||||
[[ -e $expanded_path ]] && return 0
|
if [[ -x $expanded_path ]]; then
|
||||||
|
if (( autocd )); then
|
||||||
|
if [[ -d $expanded_path ]]; then
|
||||||
|
REPLY=autodirectory
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
elif [[ ! -d $expanded_path ]]; then
|
||||||
|
# ### This seems unreachable for the current callers
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -L $expanded_path || -e $expanded_path ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Search the path in CDPATH
|
# Search the path in CDPATH
|
||||||
|
if [[ $expanded_path != /* ]] && (( autocd || ! in_command_position )); then
|
||||||
|
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
|
||||||
local cdpath_dir
|
local cdpath_dir
|
||||||
for cdpath_dir in $cdpath ; do
|
for cdpath_dir in $cdpath ; do
|
||||||
[[ -e "$cdpath_dir/$expanded_path" ]] && return 0
|
if [[ -d "$cdpath_dir/$expanded_path" && -x "$cdpath_dir/$expanded_path" ]]; then
|
||||||
|
if (( in_command_position && autocd )); then
|
||||||
|
REPLY=autodirectory
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# If dirname($1) doesn't exist, neither does $1.
|
# If dirname($1) doesn't exist, neither does $1.
|
||||||
[[ ! -d ${expanded_path:h} ]] && return 1
|
[[ ! -d ${expanded_path:h} ]] && return 1
|
||||||
|
|
||||||
# If this word ends the buffer, check if it's the prefix of a valid path.
|
# If this word ends the buffer, check if it's the prefix of a valid path.
|
||||||
if (( has_end && (len == end_pos) )) &&
|
if (( has_end && (len == end_pos) )) &&
|
||||||
|
(( ! in_alias )) &&
|
||||||
[[ $WIDGET != zle-line-finish ]]; then
|
[[ $WIDGET != zle-line-finish ]]; then
|
||||||
|
# TODO: When we've dropped support for pre-5.0.6 zsh, use the *(Y1) glob qualifier here.
|
||||||
local -a tmp
|
local -a tmp
|
||||||
|
if (( in_command_position )); then
|
||||||
|
# We include directories even when autocd is enabled, because those
|
||||||
|
# directories might contain executable files: e.g., BUFFER="/bi" en route
|
||||||
|
# to typing "/bin/sh".
|
||||||
|
tmp=( ${expanded_path}*(N-*,N-/) )
|
||||||
|
else
|
||||||
tmp=( ${expanded_path}*(N) )
|
tmp=( ${expanded_path}*(N) )
|
||||||
(( $#tmp > 0 )) && REPLY=path_prefix && return 0
|
fi
|
||||||
|
(( ${+tmp[1]} )) && REPLY=path_prefix && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# It's not a path.
|
# It's not a path.
|
||||||
@ -1008,6 +1276,8 @@ _zsh_highlight_main_highlighter_check_path()
|
|||||||
# Highlight an argument and possibly special chars in quotes starting at $1 in $arg
|
# Highlight an argument and possibly special chars in quotes starting at $1 in $arg
|
||||||
# This command will at least highlight $1 to end_pos with the default style
|
# This command will at least highlight $1 to end_pos with the default style
|
||||||
# If $2 is set to 0, the argument cannot be highlighted as an option.
|
# If $2 is set to 0, the argument cannot be highlighted as an option.
|
||||||
|
#
|
||||||
|
# This function currently assumes it's never called for the command word.
|
||||||
_zsh_highlight_main_highlighter_highlight_argument()
|
_zsh_highlight_main_highlighter_highlight_argument()
|
||||||
{
|
{
|
||||||
local base_style=default i=$1 option_eligible=${2:-1} path_eligible=1 ret start style
|
local base_style=default i=$1 option_eligible=${2:-1} path_eligible=1 ret start style
|
||||||
@ -1049,8 +1319,12 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
|
|
||||||
for (( ; i <= $#arg ; i += 1 )); do
|
# This loop is a hot path. Keep it fast!
|
||||||
|
(( --i ))
|
||||||
|
while (( ++i <= $#arg )); do
|
||||||
|
i=${arg[(ib.i.)[\\\'\"\`\$\<\>\*\?]]}
|
||||||
case "$arg[$i]" in
|
case "$arg[$i]" in
|
||||||
|
"") break;;
|
||||||
"\\") (( i += 1 )); continue;;
|
"\\") (( i += 1 )); continue;;
|
||||||
"'")
|
"'")
|
||||||
_zsh_highlight_main_highlighter_highlight_single_quote $i
|
_zsh_highlight_main_highlighter_highlight_single_quote $i
|
||||||
@ -1076,7 +1350,8 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
(( i = REPLY ))
|
(( i = REPLY ))
|
||||||
highlights+=($reply)
|
highlights+=($reply)
|
||||||
continue
|
continue
|
||||||
elif [[ $arg[i+1] == $'\x28' ]]; then
|
elif [[ $arg[i+1] == $'\x28' && ${arg:$i} != $'\x28\x28'*$'\x29\x29'* ]]; then
|
||||||
|
# command substitution that doesn't look like an arithmetic expansion
|
||||||
start=$i
|
start=$i
|
||||||
(( i += 2 ))
|
(( i += 2 ))
|
||||||
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
|
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
|
||||||
@ -1091,8 +1366,12 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
highlights+=($(( start_pos + i - 1)) $(( start_pos + i )) command-substitution-delimiter-unquoted)
|
highlights+=($(( start_pos + i - 1)) $(( start_pos + i )) command-substitution-delimiter-unquoted)
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
|
else
|
||||||
|
# TODO: if it's an arithmetic expansion, skip past it, to prevent
|
||||||
|
# multiplications from being highlighted as globbing (issue #607,
|
||||||
|
# test-data/arith1.zsh)
|
||||||
fi
|
fi
|
||||||
while [[ $arg[i+1] == [\^=~#+] ]]; do
|
while [[ $arg[i+1] == [=~#+'^'] ]]; do
|
||||||
(( i += 1 ))
|
(( i += 1 ))
|
||||||
done
|
done
|
||||||
if [[ $arg[i+1] == [*@#?$!-] ]]; then
|
if [[ $arg[i+1] == [*@#?$!-] ]]; then
|
||||||
@ -1117,7 +1396,9 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
fi
|
fi
|
||||||
;|
|
;|
|
||||||
*)
|
*)
|
||||||
if $highlight_glob && [[ ${arg[$i]} =~ ^[*?] || ${arg:$i-1} =~ ^\<[0-9]*-[0-9]*\> ]]; then
|
if $highlight_glob &&
|
||||||
|
[[ $zsyh_user_options[multios] == on || $in_redirection -eq 0 ]] &&
|
||||||
|
[[ ${arg[$i]} =~ ^[*?] || ${arg:$i-1} =~ ^\<[0-9]*-[0-9]*\> ]]; then
|
||||||
highlights+=($(( start_pos + i - 1 )) $(( start_pos + i + $#MATCH - 1)) globbing)
|
highlights+=($(( start_pos + i - 1 )) $(( start_pos + i + $#MATCH - 1)) globbing)
|
||||||
(( i += $#MATCH - 1 ))
|
(( i += $#MATCH - 1 ))
|
||||||
path_eligible=0
|
path_eligible=0
|
||||||
@ -1128,11 +1409,20 @@ _zsh_highlight_main_highlighter_highlight_argument()
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path $arg[$1,-1]; then
|
if (( path_eligible )); then
|
||||||
|
if (( in_redirection )) && [[ $last_arg == *['<>']['&'] && $arg[$1,-1] == (<0->|p|-) ]]; then
|
||||||
|
if [[ $arg[$1,-1] == (p|-) ]]; then
|
||||||
|
base_style=redirection
|
||||||
|
else
|
||||||
|
base_style=numeric-fd
|
||||||
|
fi
|
||||||
|
# This function is currently never called for the command word, so $2 is hard-coded as 0.
|
||||||
|
elif _zsh_highlight_main_highlighter_check_path $arg[$1,-1] 0; then
|
||||||
base_style=$REPLY
|
base_style=$REPLY
|
||||||
_zsh_highlight_main_highlighter_highlight_path_separators $base_style
|
_zsh_highlight_main_highlighter_highlight_path_separators $base_style
|
||||||
highlights+=($reply)
|
highlights+=($reply)
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
highlights=($(( start_pos + $1 - 1 )) $end_pos $base_style $highlights)
|
highlights=($(( start_pos + $1 - 1 )) $end_pos $base_style $highlights)
|
||||||
_zsh_highlight_main_add_many_region_highlights $highlights
|
_zsh_highlight_main_add_many_region_highlights $highlights
|
||||||
@ -1184,14 +1474,14 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
|
|||||||
(( j = i + start_pos - 1 ))
|
(( j = i + start_pos - 1 ))
|
||||||
(( k = j + 1 ))
|
(( k = j + 1 ))
|
||||||
case "$arg[$i]" in
|
case "$arg[$i]" in
|
||||||
'"') break;;
|
('"') break;;
|
||||||
'`') saved_reply=($reply)
|
('`') saved_reply=($reply)
|
||||||
_zsh_highlight_main_highlighter_highlight_backtick $i
|
_zsh_highlight_main_highlighter_highlight_backtick $i
|
||||||
(( i = REPLY ))
|
(( i = REPLY ))
|
||||||
reply=($saved_reply $reply)
|
reply=($saved_reply $reply)
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
'$' ) style=dollar-double-quoted-argument
|
('$') style=dollar-double-quoted-argument
|
||||||
# Look for an alphanumeric parameter name.
|
# Look for an alphanumeric parameter name.
|
||||||
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
|
if [[ ${arg:$i} =~ ^([A-Za-z_][A-Za-z0-9_]*|[0-9]+) ]] ; then
|
||||||
(( k += $#MATCH )) # highlight the parameter name
|
(( k += $#MATCH )) # highlight the parameter name
|
||||||
@ -1207,7 +1497,8 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
|
|||||||
# $#, $*, $@, $?, $- - like $$ above
|
# $#, $*, $@, $?, $- - like $$ above
|
||||||
(( k += 1 )) # highlight both dollar signs
|
(( k += 1 )) # highlight both dollar signs
|
||||||
(( i += 1 )) # don't consider the second one as introducing another parameter expansion
|
(( i += 1 )) # don't consider the second one as introducing another parameter expansion
|
||||||
elif [[ $arg[i+1] == $'\x28' ]]; then
|
elif [[ $arg[i+1] == $'\x28' && ${arg:$i} != $'\x28\x28'*$'\x29\x29'* ]]; then
|
||||||
|
# command substitution that doesn't look like an arithmetic expansion
|
||||||
breaks+=( $last_break $(( start_pos + i - 1 )) )
|
breaks+=( $last_break $(( start_pos + i - 1 )) )
|
||||||
(( i += 2 ))
|
(( i += 2 ))
|
||||||
saved_reply=($reply)
|
saved_reply=($reply)
|
||||||
@ -1410,6 +1701,13 @@ _zsh_highlight_main_highlighter_expand_path()
|
|||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
_zsh_highlight_main__precmd_hook() {
|
_zsh_highlight_main__precmd_hook() {
|
||||||
|
# Unset the WARN_NESTED_VAR option, taking care not to error if the option
|
||||||
|
# doesn't exist (zsh older than zsh-5.3.1-test-2).
|
||||||
|
setopt localoptions
|
||||||
|
if eval '[[ -o warnnestedvar ]]' 2>/dev/null; then
|
||||||
|
unsetopt warnnestedvar
|
||||||
|
fi
|
||||||
|
|
||||||
_zsh_highlight_main__command_type_cache=()
|
_zsh_highlight_main__command_type_cache=()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
highlighters/main/test-data/abspath-in-command-position1.zsh
Normal file
35
highlighters/main/test-data/abspath-in-command-position1.zsh
Normal 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' # /
|
||||||
|
)
|
@ -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' # /
|
||||||
|
)
|
35
highlighters/main/test-data/abspath-in-command-position2.zsh
Normal file
35
highlighters/main/test-data/abspath-in-command-position2.zsh
Normal 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
|
||||||
|
)
|
37
highlighters/main/test-data/abspath-in-command-position3.zsh
Normal file
37
highlighters/main/test-data/abspath-in-command-position3.zsh
Normal 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)
|
||||||
|
)
|
@ -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)
|
||||||
|
)
|
35
highlighters/main/test-data/abspath-in-command-position4.zsh
Normal file
35
highlighters/main/test-data/abspath-in-command-position4.zsh
Normal 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
|
||||||
|
)
|
35
highlighters/main/test-data/abspath-in-command-position5.zsh
Normal file
35
highlighters/main/test-data/abspath-in-command-position5.zsh
Normal 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
|
||||||
|
)
|
35
highlighters/main/test-data/alias-basic.zsh
Normal file
35
highlighters/main/test-data/alias-basic.zsh
Normal 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
|
||||||
|
)
|
@ -27,11 +27,11 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# see alias-comment2.zsh
|
# see alias-comment2.zsh and comment-followed.zsh
|
||||||
setopt interactivecomments
|
setopt interactivecomments
|
||||||
alias x=$'# foo\npwd'
|
alias x=$'# foo\npwd'
|
||||||
BUFFER='x'
|
BUFFER='x'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 alias "issue #616"' # x
|
'1 1 alias' # x
|
||||||
)
|
)
|
||||||
|
@ -32,5 +32,5 @@ alias ls=tmp tmp='command ls'
|
|||||||
BUFFER='ls'
|
BUFFER='ls'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 2 alias 'issue #652'" # ls
|
"1 2 alias" # ls
|
||||||
)
|
)
|
||||||
|
43
highlighters/main/test-data/alias-in-cmdsubst.zsh
Normal file
43
highlighters/main/test-data/alias-in-cmdsubst.zsh
Normal 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' # )
|
||||||
|
)
|
@ -28,12 +28,16 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function b() {} # beware of ALIAS_FUNC_DEF
|
||||||
alias a=b b=c c=b
|
alias a=b b=c c=b
|
||||||
|
|
||||||
BUFFER='a foo; :'
|
BUFFER='a foo; :'
|
||||||
|
|
||||||
expected_region_highlight=(
|
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
|
'3 5 default' # foo
|
||||||
'6 6 commandseparator' # ;
|
'6 6 commandseparator' # ;
|
||||||
'8 8 builtin' # :
|
'8 8 builtin' # :
|
||||||
|
35
highlighters/main/test-data/alias-loop2.zsh
Normal file
35
highlighters/main/test-data/alias-loop2.zsh
Normal 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
|
||||||
|
)
|
38
highlighters/main/test-data/alias-parameter.zsh
Normal file
38
highlighters/main/test-data/alias-parameter.zsh
Normal 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
|
||||||
|
)
|
@ -28,6 +28,7 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# See also param-precommand-option-argument1.zsh
|
||||||
alias sudo_u='sudo -u'
|
alias sudo_u='sudo -u'
|
||||||
sudo(){}
|
sudo(){}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# See also param-precommand-option-argument3.zsh
|
||||||
alias sudo_u='sudo -u'
|
alias sudo_u='sudo -u'
|
||||||
sudo(){}
|
sudo(){}
|
||||||
|
|
||||||
|
@ -32,5 +32,5 @@ alias x=/
|
|||||||
BUFFER=$'x'
|
BUFFER=$'x'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 unknown-token "issue #202"' # x (/)
|
'1 1 unknown-token' # x (/)
|
||||||
)
|
)
|
||||||
|
37
highlighters/main/test-data/alias-to-dir1b.zsh
Normal file
37
highlighters/main/test-data/alias-to-dir1b.zsh
Normal 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
|
||||||
|
)
|
@ -32,7 +32,7 @@ BUFFER=$'{\nls\n} always { pwd }'
|
|||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 reserved-word' # {
|
'1 1 reserved-word' # {
|
||||||
'2 2 unknown-token' # \n
|
'2 2 commandseparator' # \n
|
||||||
'3 4 command' # ls
|
'3 4 command' # ls
|
||||||
'5 5 commandseparator' # \n
|
'5 5 commandseparator' # \n
|
||||||
'6 6 reserved-word' # }
|
'6 6 reserved-word' # }
|
||||||
|
46
highlighters/main/test-data/arith-cmdsubst-mess.zsh
Normal file
46
highlighters/main/test-data/arith-cmdsubst-mess.zsh
Normal 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 "issue #704"' # $((ls); (ls))
|
||||||
|
'3 4 command-substitution-delimiter-unquoted "issue #704"' # $(
|
||||||
|
'5 5 reserved-word "issue #704"' # (
|
||||||
|
'6 7 command "issue #704"' # ls
|
||||||
|
'8 8 reserved-word "issue #704"' # )
|
||||||
|
'9 9 commandseparator "issue #704"' # ;
|
||||||
|
'11 11 reserved-word "issue #704"' # (
|
||||||
|
'12 13 command "issue #704"' # ls
|
||||||
|
'14 14 reserved-word "issue #704"' # )
|
||||||
|
'15 15 command-substitution-delimiter-unquoted "issue #704"' # )
|
||||||
|
)
|
37
highlighters/main/test-data/arith1.zsh
Normal file
37
highlighters/main/test-data/arith1.zsh
Normal 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 ))
|
||||||
|
)
|
||||||
|
expected_mismatch="currently the actual highlighting has one superfluous group that highlights the asterisk is highlighted as 'globbing'"
|
37
highlighters/main/test-data/arith2.zsh
Normal file
37
highlighters/main/test-data/arith2.zsh
Normal 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 16 default' # "$(( 6 * 9 ))"
|
||||||
|
'3 16 double-quoted-argument' # "$(( 6 * 9 ))"
|
||||||
|
)
|
44
highlighters/main/test-data/array-cmdsep1.zsh
Normal file
44
highlighters/main/test-data/array-cmdsep1.zsh
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#!/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=(
|
||||||
|
'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' # )
|
||||||
|
)
|
39
highlighters/main/test-data/array-cmdsep2.zsh
Normal file
39
highlighters/main/test-data/array-cmdsep2.zsh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/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=(
|
||||||
|
'5 7 default' # foo
|
||||||
|
'9 9 unknown-token' # ; (not commandseparator; see highlighter source code)
|
||||||
|
'11 13 default' # bar
|
||||||
|
'15 15 assign' # )
|
||||||
|
)
|
39
highlighters/main/test-data/array-cmdsep3.zsh
Normal file
39
highlighters/main/test-data/array-cmdsep3.zsh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/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=(
|
||||||
|
'5 7 default' # foo
|
||||||
|
'9 9 commandseparator' # \n
|
||||||
|
'11 13 default' # bar
|
||||||
|
'15 15 assign' # )
|
||||||
|
)
|
37
highlighters/main/test-data/assign-invalid-command.zsh
Normal file
37
highlighters/main/test-data/assign-invalid-command.zsh
Normal 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
|
||||||
|
)
|
45
highlighters/main/test-data/assign-quoted-cmdsubst.zsh
Normal file
45
highlighters/main/test-data/assign-quoted-cmdsubst.zsh
Normal 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' # )
|
||||||
|
)
|
37
highlighters/main/test-data/assign-value-quote1.zsh
Normal file
37
highlighters/main/test-data/assign-value-quote1.zsh
Normal 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"
|
||||||
|
)
|
37
highlighters/main/test-data/assign-value-quote2.zsh
Normal file
37
highlighters/main/test-data/assign-value-quote2.zsh
Normal 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"
|
||||||
|
)
|
40
highlighters/main/test-data/assignment-before-resword1.zsh
Normal file
40
highlighters/main/test-data/assignment-before-resword1.zsh
Normal 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' # }
|
||||||
|
)
|
40
highlighters/main/test-data/assignment-before-resword2.zsh
Normal file
40
highlighters/main/test-data/assignment-before-resword2.zsh
Normal 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' # )
|
||||||
|
)
|
37
highlighters/main/test-data/assignment-before-resword3.zsh
Normal file
37
highlighters/main/test-data/assignment-before-resword3.zsh
Normal 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 ))
|
||||||
|
)
|
40
highlighters/main/test-data/assignment-before-resword4.zsh
Normal file
40
highlighters/main/test-data/assignment-before-resword4.zsh
Normal 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' # ]]
|
||||||
|
)
|
38
highlighters/main/test-data/assignment-before-resword5.zsh
Normal file
38
highlighters/main/test-data/assignment-before-resword5.zsh
Normal 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' # :
|
||||||
|
)
|
37
highlighters/main/test-data/assignment-quoted.zsh
Normal file
37
highlighters/main/test-data/assignment-quoted.zsh
Normal 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"
|
||||||
|
)
|
37
highlighters/main/test-data/backslash-continuation2.zsh
Normal file
37
highlighters/main/test-data/backslash-continuation2.zsh
Normal 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"
|
||||||
|
)
|
34
highlighters/main/test-data/backslash.zsh
Normal file
34
highlighters/main/test-data/backslash.zsh
Normal 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' # \\
|
||||||
|
)
|
38
highlighters/main/test-data/cdpath-abspath.zsh
Normal file
38
highlighters/main/test-data/cdpath-abspath.zsh
Normal 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 (/)
|
||||||
|
)
|
44
highlighters/main/test-data/cmdpos-elision-partial.zsh
Normal file
44
highlighters/main/test-data/cmdpos-elision-partial.zsh
Normal 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
|
||||||
|
)
|
@ -28,11 +28,12 @@
|
|||||||
# vim: ft=zsh sw=2 ts=2 et
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
# -------------------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# see alias-comment1.zsh
|
||||||
setopt interactivecomments
|
setopt interactivecomments
|
||||||
BUFFER=$'# foo\ntrue'
|
BUFFER=$'# foo\ntrue'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 5 comment' # # foo
|
'1 5 comment' # # foo
|
||||||
'6 6 commandseparator "issue #501"' # \n
|
'6 6 commandseparator' # \n
|
||||||
'7 10 builtin' # true
|
'7 10 builtin' # true
|
||||||
)
|
)
|
||||||
|
41
highlighters/main/test-data/dinbrack1.zsh
Normal file
41
highlighters/main/test-data/dinbrack1.zsh
Normal 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' # ]]
|
||||||
|
)
|
@ -34,6 +34,6 @@ BUFFER=$':;\n:'
|
|||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
'1 1 builtin' # :
|
'1 1 builtin' # :
|
||||||
'2 2 commandseparator' # ;
|
'2 2 commandseparator' # ;
|
||||||
'3 3 commandseparator "issue #616"' # \n
|
'3 3 commandseparator' # \n
|
||||||
'4 4 builtin' # :
|
'4 4 builtin' # :
|
||||||
)
|
)
|
||||||
|
36
highlighters/main/test-data/equals1.zsh
Normal file
36
highlighters/main/test-data/equals1.zsh
Normal 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
|
||||||
|
)
|
38
highlighters/main/test-data/equals2.zsh
Normal file
38
highlighters/main/test-data/equals2.zsh
Normal 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
|
||||||
|
)
|
36
highlighters/main/test-data/equals3.zsh
Normal file
36
highlighters/main/test-data/equals3.zsh
Normal 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
|
||||||
|
)
|
36
highlighters/main/test-data/equals4.zsh
Normal file
36
highlighters/main/test-data/equals4.zsh
Normal 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' # =
|
||||||
|
)
|
40
highlighters/main/test-data/fd-target-not-filename.zsh
Normal file
40
highlighters/main/test-data/fd-target-not-filename.zsh
Normal 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)
|
||||||
|
)
|
38
highlighters/main/test-data/global-alias1.zsh
Normal file
38
highlighters/main/test-data/global-alias1.zsh
Normal 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
|
||||||
|
)
|
@ -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' # !!
|
||||||
|
)
|
49
highlighters/main/test-data/meta-no-eval1.zsh
Normal file
49
highlighters/main/test-data/meta-no-eval1.zsh
Normal 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' # )
|
||||||
|
)
|
40
highlighters/main/test-data/meta-no-eval2.zsh
Normal file
40
highlighters/main/test-data/meta-no-eval2.zsh
Normal 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' # *
|
||||||
|
)
|
@ -35,5 +35,5 @@ expected_region_highlight=(
|
|||||||
'6 6 commandseparator' # \n
|
'6 6 commandseparator' # \n
|
||||||
'7 9 default' # bar
|
'7 9 default' # bar
|
||||||
'10 10 assign' # )
|
'10 10 assign' # )
|
||||||
'12 14 command' # env
|
'12 14 precommand' # env
|
||||||
)
|
)
|
||||||
|
39
highlighters/main/test-data/multios-negates-globbing.zsh
Normal file
39
highlighters/main/test-data/multios-negates-globbing.zsh
Normal 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
|
||||||
|
)
|
38
highlighters/main/test-data/multios-negates-globbing2.zsh
Normal file
38
highlighters/main/test-data/multios-negates-globbing2.zsh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2018 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$'cat < *'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 command' # cat
|
||||||
|
'5 5 redirection' # <
|
||||||
|
'7 7 default' # *
|
||||||
|
'7 7 globbing' # *
|
||||||
|
)
|
@ -39,6 +39,7 @@ expected_region_highlight=(
|
|||||||
'19 24 reserved-word' # always
|
'19 24 reserved-word' # always
|
||||||
'26 26 reserved-word' # {
|
'26 26 reserved-word' # {
|
||||||
'28 31 builtin' # echo
|
'28 31 builtin' # echo
|
||||||
'33 33 globbing "issue #577"' # *
|
'33 33 default' # *
|
||||||
|
'33 33 globbing' # *
|
||||||
'35 35 reserved-word' # }
|
'35 35 reserved-word' # }
|
||||||
)
|
)
|
||||||
|
38
highlighters/main/test-data/null-exec.zsh
Normal file
38
highlighters/main/test-data/null-exec.zsh
Normal 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=$'exec >/dev/null;'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 precommand' # exec
|
||||||
|
'6 6 redirection' # >
|
||||||
|
'7 15 path' # /dev/null
|
||||||
|
'16 16 commandseparator' # ;
|
||||||
|
)
|
40
highlighters/main/test-data/opt-shwordsplit1.zsh
Normal file
40
highlighters/main/test-data/opt-shwordsplit1.zsh
Normal 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
setopt shwordsplit
|
||||||
|
local EDITOR='ed -s'
|
||||||
|
|
||||||
|
ed() { command ed "$@" }
|
||||||
|
|
||||||
|
BUFFER=$'$EDITOR'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 function "issue #687"' # $EDITOR
|
||||||
|
)
|
43
highlighters/main/test-data/optimized-cmdsubst-input.zsh
Normal file
43
highlighters/main/test-data/optimized-cmdsubst-input.zsh
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2018 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# See getoutput() and getoutputfile() in zsh's C source code.
|
||||||
|
|
||||||
|
BUFFER=$': $(<*)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 7 default' # $(<*)
|
||||||
|
'3 7 command-substitution-unquoted' # $(<*)
|
||||||
|
'3 4 command-substitution-delimiter-unquoted' # $(
|
||||||
|
'5 5 redirection' # <
|
||||||
|
'6 6 default' # * - not globbing!
|
||||||
|
'7 7 command-substitution-delimiter-unquoted' # )
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# This used to be an infinite loop.
|
||||||
|
|
||||||
|
BUFFER=$'l+=( $1'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 assign' # l+=(
|
||||||
|
'6 7 default' # $1
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# See also alias-precommand-option-argument1.zsh
|
||||||
|
local -a sudo_u; sudo_u=(sudo -u)
|
||||||
|
sudo(){}
|
||||||
|
|
||||||
|
BUFFER='$sudo_u phy1729 echo foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 precommand' # $sudo_u
|
||||||
|
'9 15 default' # phy1729
|
||||||
|
'18 20 command "issue #540"' # echo (not builtin)
|
||||||
|
'22 24 default' # foo
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# See also alias-precommand-option-argument3.zsh
|
||||||
|
local -a sudo_u; sudo_u=(sudo -u)
|
||||||
|
sudo(){}
|
||||||
|
|
||||||
|
BUFFER='$sudo_u phy1729 ls foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 7 precommand' # sudo_u
|
||||||
|
'9 15 default' # phy1729
|
||||||
|
'17 18 command' # ls
|
||||||
|
'20 22 default' # foo
|
||||||
|
)
|
@ -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='$x ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 comment' # $x
|
||||||
|
'4 5 command' # ls
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local x="()"
|
||||||
|
|
||||||
|
BUFFER=$'$x ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 unknown-token' # $x
|
||||||
|
'4 5 command' # ls
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local x="^foo^bar"
|
||||||
|
|
||||||
|
BUFFER=$'$x ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 unknown-token' # $x
|
||||||
|
'4 5 default' # ls
|
||||||
|
)
|
38
highlighters/main/test-data/parameter-to-global-alias.zsh
Normal file
38
highlighters/main/test-data/parameter-to-global-alias.zsh
Normal 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 x=y
|
||||||
|
local s=x
|
||||||
|
|
||||||
|
BUFFER=$'$s'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 2 unknown-token' # $s
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local foobar='x=$(ls)'
|
||||||
|
|
||||||
|
BUFFER=$'$foobar'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
# Used to highlight the "ba" as 'command' because the 'ls' showed through; issues #670 and #674
|
||||||
|
'1 7 unknown-token' # $foobar (not an assignment)
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
local y='x=$(ls)'
|
||||||
|
|
||||||
|
BUFFER=$'$y'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
# Used to trigger a "BUG" message on stderr - issues #670 and #674
|
||||||
|
'1 2 unknown-token' # $y (not an assignment)
|
||||||
|
)
|
38
highlighters/main/test-data/pasted-quotes.zsh
Normal file
38
highlighters/main/test-data/pasted-quotes.zsh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2013 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 1 builtin' # :
|
||||||
|
'3 15 default' # \'foo\'bar"baz"
|
||||||
|
'3 7 single-quoted-argument' # \'foo\'
|
||||||
|
'11 15 double-quoted-argument' # "baz"
|
||||||
|
)
|
@ -34,7 +34,7 @@
|
|||||||
BUFFER='$PWD; ${PWD}'
|
BUFFER='$PWD; ${PWD}'
|
||||||
|
|
||||||
expected_region_highlight=(
|
expected_region_highlight=(
|
||||||
"1 4 path" # $PWD
|
"1 4 unknown-token" # $PWD (without AUTO_CD)
|
||||||
"5 5 commandseparator" # ;
|
"5 5 commandseparator" # ;
|
||||||
"7 12 path" # ${PWD}
|
"7 12 path_prefix" # ${PWD}
|
||||||
)
|
)
|
||||||
|
38
highlighters/main/test-data/path-dollared-word3b.zsh
Normal file
38
highlighters/main/test-data/path-dollared-word3b.zsh
Normal 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=$'$PWD; ${PWD}'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 autodirectory' # $PWD
|
||||||
|
'5 5 commandseparator' # ;
|
||||||
|
'7 12 autodirectory' # ${PWD}
|
||||||
|
)
|
39
highlighters/main/test-data/path-mixed-quoting.zsh
Normal file
39
highlighters/main/test-data/path-mixed-quoting.zsh
Normal 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
touch foo
|
||||||
|
|
||||||
|
BUFFER=$': \'f\'oo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 7 path' # \'f\'oo
|
||||||
|
'3 5 single-quoted-argument' # \'f\'
|
||||||
|
)
|
@ -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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
touch foo
|
||||||
|
chmod -x foo
|
||||||
|
BUFFER=$'./foo; ./foo'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 5 unknown-token' # ./foo (in middle)
|
||||||
|
'6 6 commandseparator' # ;
|
||||||
|
'8 12 unknown-token' # ./foo (at end)
|
||||||
|
)
|
39
highlighters/main/test-data/precommand-killing1.zsh
Normal file
39
highlighters/main/test-data/precommand-killing1.zsh
Normal 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
hash sudo=false
|
||||||
|
|
||||||
|
BUFFER='sudo -e /etc/passwd'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 precommand' # sudo
|
||||||
|
'6 7 single-hyphen-option' # -e
|
||||||
|
'9 19 path' # /etc/passwd
|
||||||
|
)
|
39
highlighters/main/test-data/precommand-killing2.zsh
Normal file
39
highlighters/main/test-data/precommand-killing2.zsh
Normal 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
hash sudo=false
|
||||||
|
|
||||||
|
BUFFER='sudo -e /does/not/exist'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 precommand' # sudo
|
||||||
|
'6 7 single-hyphen-option' # -e
|
||||||
|
'9 23 default' # /does/not/exist
|
||||||
|
)
|
37
highlighters/main/test-data/precommand-then-assignment.zsh
Normal file
37
highlighters/main/test-data/precommand-then-assignment.zsh
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/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=$'nice x=y ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 precommand' # nice
|
||||||
|
'6 8 unknown-token "issue #641.5"' # x=y
|
||||||
|
'10 11 default "issue #641.5 (fallout)"' # ls
|
||||||
|
)
|
44
highlighters/main/test-data/precommand-uninstalled.zsh
Normal file
44
highlighters/main/test-data/precommand-uninstalled.zsh
Normal 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Simulate sudo not being installed.
|
||||||
|
#
|
||||||
|
# The 'hash' step is because, if sudo _really_ isn't installed, 'unhash sudo'
|
||||||
|
# would error out and break the test.
|
||||||
|
hash sudo=/usr/bin/env && unhash sudo
|
||||||
|
|
||||||
|
local PATH
|
||||||
|
|
||||||
|
BUFFER=$'sudo ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 unknown-token' # sudo
|
||||||
|
'6 7 default' # ls - not 'command', since sudo isn't installed
|
||||||
|
)
|
@ -38,6 +38,6 @@ expected_region_highlight=(
|
|||||||
'10 11 command' # ls
|
'10 11 command' # ls
|
||||||
'12 12 commandseparator' # ;
|
'12 12 commandseparator' # ;
|
||||||
'14 17 precommand' # sudo
|
'14 17 precommand' # sudo
|
||||||
'19 20 unknown-token' # -x
|
'19 20 single-hyphen-option' # -x
|
||||||
'22 23 command' # ls
|
'22 23 command' # ls
|
||||||
)
|
)
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2017, 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=$'< <(pwd) > >(nl)'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 redirection' # <
|
||||||
|
'3 8 default' # <(pwd)
|
||||||
|
'3 8 process-substitution' # <(pwd)
|
||||||
|
'3 4 process-substitution-delimiter' # <(
|
||||||
|
'5 7 builtin' # pwd
|
||||||
|
'8 8 process-substitution-delimiter' # )
|
||||||
|
'10 10 redirection' # >
|
||||||
|
'12 16 default' # >(nl)
|
||||||
|
'12 16 process-substitution' # >(nl)
|
||||||
|
'12 13 process-substitution-delimiter' # >(
|
||||||
|
'14 15 command' # nl
|
||||||
|
'16 16 process-substitution-delimiter' # )
|
||||||
|
)
|
@ -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=$'">" foo ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 unknown-token' # ">" - not "redirection"
|
||||||
|
'5 7 default' # foo
|
||||||
|
'9 10 default' # ls - not "command"
|
||||||
|
)
|
38
highlighters/main/test-data/redirection-inhibits-elision.zsh
Normal file
38
highlighters/main/test-data/redirection-inhibits-elision.zsh
Normal 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=$'<$foo cat cat'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 redirection' # <
|
||||||
|
'2 5 default' # $foo
|
||||||
|
'7 9 command' # cat
|
||||||
|
'11 13 default' # cat
|
||||||
|
)
|
38
highlighters/main/test-data/redirection-is-not-option.zsh
Normal file
38
highlighters/main/test-data/redirection-is-not-option.zsh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2018 zsh-syntax-highlighting contributors
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted
|
||||||
|
# provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# * Redistributions of source code must retain the above copyright notice, this list of conditions
|
||||||
|
# and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright notice, this list of
|
||||||
|
# conditions and the following disclaimer in the documentation and/or other materials provided
|
||||||
|
# with the distribution.
|
||||||
|
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
|
||||||
|
# may be used to endorse or promote products derived from this software without specific prior
|
||||||
|
# written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
|
||||||
|
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||||
|
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
BUFFER=$': > -x >> --yy'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 1 builtin' # :
|
||||||
|
'3 3 redirection' # >
|
||||||
|
'5 6 default' # -x
|
||||||
|
'8 9 redirection' # >>
|
||||||
|
'11 14 default' # --yy
|
||||||
|
)
|
44
highlighters/main/test-data/redirection-special-cases.zsh
Normal file
44
highlighters/main/test-data/redirection-special-cases.zsh
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#!/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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# See xpandredir() in the zsh source.
|
||||||
|
|
||||||
|
BUFFER=$'cat <&p; exec {myfd}>&-'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 3 command' # cat
|
||||||
|
'5 6 redirection' # <&
|
||||||
|
'7 7 redirection' # p
|
||||||
|
'8 8 commandseparator' # ;
|
||||||
|
'10 13 precommand' # exec
|
||||||
|
'15 20 named-fd' # {myfd}
|
||||||
|
'21 22 redirection' # >&
|
||||||
|
'23 23 redirection' # -
|
||||||
|
)
|
38
highlighters/main/test-data/sudo-longopt.zsh
Normal file
38
highlighters/main/test-data/sudo-longopt.zsh
Normal 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
|
||||||
|
# -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
hash sudo='false'
|
||||||
|
BUFFER='sudo --askpass ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 precommand' # sudo
|
||||||
|
'6 14 double-hyphen-option' # --askpass
|
||||||
|
'16 17 command' # ls (we don't know whether --askpass takes an argument)
|
||||||
|
)
|
39
highlighters/main/test-data/time-and-nocorrect1.zsh
Normal file
39
highlighters/main/test-data/time-and-nocorrect1.zsh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/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=$'time ls; nocorrect ls'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 reserved-word' # time
|
||||||
|
'6 7 command' # ls
|
||||||
|
'8 8 commandseparator' # ;
|
||||||
|
'10 18 reserved-word' # nocorrect
|
||||||
|
'20 21 command' # ls
|
||||||
|
)
|
40
highlighters/main/test-data/time-and-nocorrect2.zsh
Normal file
40
highlighters/main/test-data/time-and-nocorrect2.zsh
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#!/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=$'time ls; nocorrect ls'
|
||||||
|
alias time=':' nocorrect=':'
|
||||||
|
|
||||||
|
expected_region_highlight=(
|
||||||
|
'1 4 alias' # time
|
||||||
|
'6 7 default' # ls
|
||||||
|
'8 8 commandseparator' # ;
|
||||||
|
'10 18 alias' # nocorrect
|
||||||
|
'20 21 default' # ls
|
||||||
|
)
|
BIN
images/after4-smaller.png
Normal file
BIN
images/after4-smaller.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
images/before4-smaller.png
Normal file
BIN
images/before4-smaller.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
@ -5,11 +5,13 @@
|
|||||||
- Check open issues and outstanding pull requests
|
- Check open issues and outstanding pull requests
|
||||||
- Confirm `make test` passes
|
- Confirm `make test` passes
|
||||||
- check with multiple zsh versions
|
- check with multiple zsh versions
|
||||||
|
(easiest to check travis: https://travis-ci.org/zsh-users/zsh-syntax-highlighting/)
|
||||||
- Update changelog.md
|
- Update changelog.md
|
||||||
`tig --abbrev=12 --abbrev-commit 0.4.1..upstream/master`
|
`tig --abbrev=12 --abbrev-commit 0.4.1..upstream/master`
|
||||||
- Remove `-dev` suffix from `./.version`;
|
- Make sure there are no local commits and that `git status` is clean;
|
||||||
|
Remove `-dev` suffix from `./.version`;
|
||||||
Commit that using `git commit -m "Tag version $(<.version)." .version`;
|
Commit that using `git commit -m "Tag version $(<.version)." .version`;
|
||||||
Tag it using `git tag -s -m "Tag version $(<.version)"`;
|
Tag it using `git tag -s -m "Tag version $(<.version)" $(<.version)`;
|
||||||
Increment `./.version` and restore the `-dev` suffix;
|
Increment `./.version` and restore the `-dev` suffix;
|
||||||
Commit that using `git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5 .version`.
|
Commit that using `git commit -C b5c30ae52638e81a38fe5329081c5613d7bd6ca5 .version`.
|
||||||
- Push with `git push && git push --tags`
|
- Push with `git push && git push --tags`
|
||||||
|
@ -7,6 +7,9 @@ The tests harness expects the highlighter directory to contain a `test-data`
|
|||||||
directory with test data files.
|
directory with test data files.
|
||||||
See the [main highlighter](../highlighters/main/test-data) for examples.
|
See the [main highlighter](../highlighters/main/test-data) for examples.
|
||||||
|
|
||||||
|
Tests should set the following variables:
|
||||||
|
|
||||||
|
1.
|
||||||
Each test should define the string `$BUFFER` that is to be highlighted and the
|
Each test should define the string `$BUFFER` that is to be highlighted and the
|
||||||
array parameter `$expected_region_highlight`.
|
array parameter `$expected_region_highlight`.
|
||||||
The value of that parameter is a list of strings of the form `"$i $j $style"`.
|
The value of that parameter is a list of strings of the form `"$i $j $style"`.
|
||||||
@ -16,15 +19,26 @@ that is, `$i` and `$j` specify a range, 1-indexed, inclusive of both endpoints.
|
|||||||
`$style` is a key of `$ZSH_HIGHLIGHT_STYLES`.
|
`$style` is a key of `$ZSH_HIGHLIGHT_STYLES`.
|
||||||
If `$todo` exists, the test point is marked as TODO (the failure of that test
|
If `$todo` exists, the test point is marked as TODO (the failure of that test
|
||||||
point will not fail the test), and `$todo` is used as the explanation.
|
point will not fail the test), and `$todo` is used as the explanation.
|
||||||
|
|
||||||
|
2.
|
||||||
If a test sets `$skip_test` to a non-empty string, the test will be skipped
|
If a test sets `$skip_test` to a non-empty string, the test will be skipped
|
||||||
with the provided string as the reason.
|
with the provided string as the reason.
|
||||||
|
|
||||||
|
3.
|
||||||
|
If a test sets `$fail_test` to a non-empty string, the test will be skipped
|
||||||
|
with the provided string as the reason.
|
||||||
|
|
||||||
|
4.
|
||||||
If a test sets `unsorted=1` the order of highlights in `$expected_region_highlight`
|
If a test sets `unsorted=1` the order of highlights in `$expected_region_highlight`
|
||||||
need not match the order in `$region_highlight`.
|
need not match the order in `$region_highlight`.
|
||||||
|
|
||||||
|
5.
|
||||||
Normally, tests fail if `$expected_region_highlight` and `$region_highlight`
|
Normally, tests fail if `$expected_region_highlight` and `$region_highlight`
|
||||||
have different numbers of elements. Tests may set `$expected_mismatch` to an
|
have different numbers of elements. To mark this check as expected to fail,
|
||||||
explanation string (like `$todo`) to avoid this and mark the cardinality check
|
tests may set `$expected_mismatch` to an explanation string (like `$todo`);
|
||||||
as todo.
|
this is useful when the only difference between actual and expected is that actual
|
||||||
|
has some additional, superfluous elements. This check is skipped if the
|
||||||
|
`$todo` component is present in any regular test point.
|
||||||
|
|
||||||
**Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but
|
**Note**: `$region_highlight` uses the same `"$i $j $style"` syntax but
|
||||||
interprets the indexes differently.
|
interprets the indexes differently.
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user