20 Commits

Author SHA1 Message Date
Daniel Shahaf
71dc090d02 Tag version 0.7.0-beta1. 2020-01-11 23:34:58 +00:00
Daniel Shahaf
6a310ada5b changelog: Add three entries 2020-01-11 23:31:18 +00:00
Daniel Shahaf
c1d5790c57 changelog: Start 0.7.0's changelog. 2020-01-11 23:10:28 +00:00
Daniel Shahaf
e9b1ce1a36 Add a unit test for dc1b2f6fa4. 2020-01-11 23:04:22 +00:00
Daniel Shahaf
68fbe1a449 Add a test for redirection from/to process substitution.
Inspired by ab1013ae0d.
2020-01-11 21:47:34 +00:00
Daniel Shahaf
f02c0bf980 Don't describe as ZSH_HIGHLIGHT_DIRS_BLACKLIST as experimental, now that it's named without the X_ prefix. 2020-01-11 21:32:21 +00:00
Daniel Shahaf
1be58a6f45 Add a test for 2f03b6d704. 2020-01-11 21:19:52 +00:00
Daniel Shahaf
c0ad50e645 dev tools: Fix regression introduced in commit "Print the test data to stdout for convenience.".
tee(1) truncated $fname.  Fortunately, the data that got truncated had just
been `git add`-ed, so no harm was done.
2020-01-11 20:49:12 +00:00
Daniel Shahaf
8b2768ab40 'main': Add a test for 07f259f653. 2020-01-11 20:46:14 +00:00
Daniel Shahaf
6f1f595e3e dev tools: Print the test data to stdout for convenience. 2020-01-07 19:59:49 +00:00
Daniel Shahaf
de95d50bce 'main': Fix highlighting of the 'time' and 'nocorrect reserved words
Also add tests.

'time' is a regression from 6647e88606
(last Wednesday).
2019-12-27 13:47:31 +00:00
Daniel Shahaf
83862c1abb 'main': Add two basic tests for aliases. 2019-12-27 09:37:23 +00:00
Daniel Shahaf
ce10f20e77 'main': Add a regression test for #652. 2019-12-27 09:00:36 +00:00
Daniel Shahaf
6647e88606 'main': Add some precommands. 2019-12-25 10:53:42 +00:00
Matthew Martin
e7d3fbc50b main: Add test for previous 2019-11-07 19:59:00 -06:00
Matthew Martin
139ea2b189 main: Avoid $end_pos when calculating $arg size
Fixes second issue filed under #617
https://github.com/zsh-users/zsh-syntax-highlighting/issues/617#issuecomment-551253422

In the case of a command substitution in an alias, $arg[i,end_pos] would
not pass to the end of $arg and i <= start_pos - end_pos would not
iterate over all of $arg. Use $arg[i,-1] and $#arg respectively to avoid
issues in aliases.
2019-11-07 19:50:17 -06:00
Oliver Kiddle
be3882aeb0 driver: adjust region end for vi command mode 2019-10-17 21:18:56 +00:00
Daniel Shahaf
35c8690c00 release.md: Document that release tags should be signed.
That's how the previous tags were done.
2019-08-01 15:02:07 +00:00
Matthew Martin
b55832c5f8 main: Drop X_ from X_ZSH_HIGHLIGHT_DIRS_BLACKLIST 2019-07-24 07:27:54 -05:00
Daniel Shahaf
8e78e9dbba 'main': Fix issue #623 by fixing the expectations of the regression test of issue #616. 2019-07-21 01:44:19 +00:00
28 changed files with 598 additions and 136 deletions

View File

@@ -1 +1 @@
0.7.0-dev 0.7.0-beta1

View File

@@ -1,5 +1,3 @@
**This branch will be rebased from time to time.**
zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis] zsh-syntax-highlighting [![Build Status][build-status-image]][build-status-travis]
======================= =======================

View File

@@ -1,3 +1,69 @@
# Changes in version 0.7.0
**Version 0.7.0 has not been released. This changelog is a work in progress.**
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 improvement 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]
# 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.

View File

@@ -44,18 +44,6 @@ page][zshzle-Character-Highlighting].
[zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting [zshzle-Character-Highlighting]: http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Character-Highlighting
Styles may be set directly or by themes. If no theme is specified in
`ZSH_HIGHLIGHT_THEME` the `default` theme will be loaded. Additional themes
may be layered on top (overriding previous theme's settings) by calling
`_zsh_highlight_load_theme`. `_zsh_highlight_load_theme` takes either an
absolute path to a theme file to load or a theme name. For a theme name the
base theme from the themes directory is loaded and then the extensions of the
theme that any active highlighter has are loaded. Names must not contain a `/`.
The `default` theme is a colorful theme that preserves the defaults the
highlighters originally had. The `error-only` theme is also available for
highlighting only syntax errors.
Some highlighters support additional configuration parameters; see each Some highlighters support additional configuration parameters; see each
highlighter's documentation for details and examples. highlighter's documentation for details and examples.
@@ -82,8 +70,13 @@ To create your own `acme` highlighter:
* Implement the `_zsh_highlight_highlighter_acme_paint` function. * Implement the `_zsh_highlight_highlighter_acme_paint` function.
This function does the actual syntax highlighting, by calling This function does the actual syntax highlighting, by calling
`_zsh_highlight_add_highlight` with the start and end of the region to `_zsh_highlight_add_highlight` with the start and end of the region to
be highlighted and the `ZSH_HIGHLIGHT_STYLES` key to use. The key should be highlighted and the `ZSH_HIGHLIGHT_STYLES` key to use. Define the default
be prefixed with your highlighter name and a colon style for that key in the highlighter script outside of any function with
`: ${ZSH_HIGHLIGHT_STYLES[key]:=value}`, being sure to prefix
the key with your highlighter name and a colon. For example:
```zsh
: ${ZSH_HIGHLIGHT_STYLES[acme:aurora]:=fg=green}
_zsh_highlight_highlighter_acme_paint() { _zsh_highlight_highlighter_acme_paint() {
# Colorize the whole buffer with the 'aurora' style # Colorize the whole buffer with the 'aurora' style
@@ -113,15 +106,6 @@ To create your own `acme` highlighter:
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 a future major or minor release (v0.x.0 or v1.0.0).
* Optionally extended the built-in themes in
`highlighters/${myhighlighter}/themes/${themename}`.
Define the theme's style for that key with `ZSH_HIGHLIGHT_STYLES[key]=value`,
being sure to prefix the key with your highlighter name and a colon. For
example:
ZSH_HIGHLIGHT_STYLES[myhighlighter:aurora]=fg=green
* Activate your highlighter in `~/.zshrc`: * Activate your highlighter in `~/.zshrc`:
```zsh ```zsh

View File

@@ -85,11 +85,10 @@ manual page][zshzle-Character-Highlighting].
#### Parameters #### Parameters
To avoid partial path lookups on a path, add the path to the `X_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
X_ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share) ZSH_HIGHLIGHT_DIRS_BLACKLIST+=(/mnt/slow_share)
``` ```
### Useless trivia ### Useless trivia

View File

@@ -28,6 +28,15 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[bracket-error]:=fg=red,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-1]:=fg=blue,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-2]:=fg=green,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-3]:=fg=magenta,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-4]:=fg=yellow,bold}
: ${ZSH_HIGHLIGHT_STYLES[bracket-level-5]:=fg=cyan,bold}
: ${ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]:=standout}
# Whether the brackets highlighter should be called or not. # Whether the brackets highlighter should be called or not.
_zsh_highlight_highlighter_brackets_predicate() _zsh_highlight_highlighter_brackets_predicate()
{ {

View File

@@ -28,6 +28,9 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[cursor]:=standout}
# Whether the cursor highlighter should be called or not. # Whether the cursor highlighter should be called or not.
_zsh_highlight_highlighter_cursor_predicate() _zsh_highlight_highlighter_cursor_predicate()
{ {

View File

@@ -28,6 +28,9 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[line]:=}
# Whether the root highlighter should be called or not. # Whether the root highlighter should be called or not.
_zsh_highlight_highlighter_line_predicate() _zsh_highlight_highlighter_line_predicate()
{ {

View File

@@ -28,6 +28,39 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[default]:=none}
: ${ZSH_HIGHLIGHT_STYLES[unknown-token]:=fg=red,bold}
: ${ZSH_HIGHLIGHT_STYLES[reserved-word]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[suffix-alias]:=fg=green,underline}
: ${ZSH_HIGHLIGHT_STYLES[precommand]:=fg=green,underline}
: ${ZSH_HIGHLIGHT_STYLES[commandseparator]:=none}
: ${ZSH_HIGHLIGHT_STYLES[path]:=underline}
: ${ZSH_HIGHLIGHT_STYLES[path_pathseparator]:=}
: ${ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]:=}
: ${ZSH_HIGHLIGHT_STYLES[globbing]:=fg=blue}
: ${ZSH_HIGHLIGHT_STYLES[history-expansion]:=fg=blue}
: ${ZSH_HIGHLIGHT_STYLES[command-substitution]:=none}
: ${ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]:=fg=magenta}
: ${ZSH_HIGHLIGHT_STYLES[process-substitution]:=none}
: ${ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]:=fg=magenta}
: ${ZSH_HIGHLIGHT_STYLES[single-hyphen-option]:=none}
: ${ZSH_HIGHLIGHT_STYLES[double-hyphen-option]:=none}
: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument]:=none}
: ${ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]:=fg=magenta}
: ${ZSH_HIGHLIGHT_STYLES[single-quoted-argument]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[double-quoted-argument]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]:=fg=yellow}
: ${ZSH_HIGHLIGHT_STYLES[rc-quote]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]:=fg=cyan}
: ${ZSH_HIGHLIGHT_STYLES[assign]:=none}
: ${ZSH_HIGHLIGHT_STYLES[redirection]:=none}
: ${ZSH_HIGHLIGHT_STYLES[comment]:=fg=black,bold}
: ${ZSH_HIGHLIGHT_STYLES[named-fd]:=none}
: ${ZSH_HIGHLIGHT_STYLES[arg0]:=fg=green}
# Whether the highlighter should be called or not. # Whether the highlighter should be called or not.
_zsh_highlight_highlighter_main_predicate() _zsh_highlight_highlighter_main_predicate()
{ {
@@ -276,14 +309,18 @@ _zsh_highlight_highlighter_main_paint()
'builtin' '' 'builtin' ''
'command' :pvV 'command' :pvV
'exec' a:cl 'exec' a:cl
'nocorrect' ''
'noglob' '' 'noglob' ''
# '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 'sudo' Cgprtu:AEHKPSVbhiklnsv # as of sudo 1.8.21p2
'stdbuf' ioe: 'stdbuf' ioe:
'eatmydata' ''
'catchsegv' ''
'nohup' ''
'setsid' :wc
) )
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
@@ -322,6 +359,12 @@ _zsh_highlight_highlighter_main_paint()
'!' # reserved word; unrelated to $histchars[1] '!' # reserved word; unrelated to $histchars[1]
) )
if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then
print >&2 'zsh-syntax-highlighting: X_ZSH_HIGHLIGHT_DIRS_BLACKLIST is deprecated. Please use ZSH_HIGHLIGHT_DIRS_BLACKLIST.'
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($X_ZSH_HIGHLIGHT_DIRS_BLACKLIST)
unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
fi
_zsh_highlight_main_highlighter_highlight_list -$#PREBUFFER '' 1 "$PREBUFFER$BUFFER" _zsh_highlight_main_highlighter_highlight_list -$#PREBUFFER '' 1 "$PREBUFFER$BUFFER"
# end is a reserved word # end is a reserved word
@@ -679,6 +722,10 @@ _zsh_highlight_main_highlighter_highlight_list()
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"
;; ;;
@@ -768,7 +815,7 @@ _zsh_highlight_main_highlighter_highlight_list()
# Discard :start_of_pipeline:, if present, as '!' is not valid # Discard :start_of_pipeline:, if present, as '!' is not valid
# after assignments. # after assignments.
next_word+=':start:' next_word+=':start:'
if (( start_pos + i <= end_pos )); then if (( i <= $#arg )); then
() { () {
local highlight_glob=false local highlight_glob=false
[[ $zsyh_user_options[globassign] == on ]] && highlight_glob=true [[ $zsyh_user_options[globassign] == on ]] && highlight_glob=true
@@ -933,7 +980,7 @@ _zsh_highlight_main_highlighter_check_path()
tmp_path=$tmp_path:a tmp_path=$tmp_path:a
while [[ $tmp_path != / ]]; do while [[ $tmp_path != / ]]; do
[[ -n ${(M)X_ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1 [[ -n ${(M)ZSH_HIGHLIGHT_DIRS_BLACKLIST:#$tmp_path} ]] && return 1
tmp_path=$tmp_path:h tmp_path=$tmp_path:h
done done
@@ -991,7 +1038,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
'=') '=')
if [[ $arg[i+1] == $'\x28' ]]; then if [[ $arg[i+1] == $'\x28' ]]; then
(( i += 2 )) (( i += 2 ))
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
highlights+=( highlights+=(
@@ -1005,7 +1052,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
fi fi
esac esac
for (( ; i <= end_pos - start_pos ; i += 1 )); do for (( ; i <= $#arg ; i += 1 )); do
case "$arg[$i]" in case "$arg[$i]" in
"\\") (( i += 1 )); continue;; "\\") (( i += 1 )); continue;;
"'") "'")
@@ -1035,7 +1082,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
elif [[ $arg[i+1] == $'\x28' ]]; then elif [[ $arg[i+1] == $'\x28' ]]; then
start=$i start=$i
(( i += 2 )) (( i += 2 ))
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
highlights+=( highlights+=(
@@ -1058,7 +1105,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
if [[ $arg[i+1] == $'\x28' ]]; then # \x28 = open paren if [[ $arg[i+1] == $'\x28' ]]; then # \x28 = open paren
start=$i start=$i
(( i += 2 )) (( i += 2 ))
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
highlights+=( highlights+=(
@@ -1084,7 +1131,7 @@ _zsh_highlight_main_highlighter_highlight_argument()
esac esac
done done
if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path $arg[$1,end_pos]; then if (( path_eligible )) && _zsh_highlight_main_highlighter_check_path $arg[$1,-1]; 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)
@@ -1136,7 +1183,7 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
local i j k ret style local i j k ret style
reply=() reply=()
for (( i = $1 + 1 ; i <= end_pos - start_pos ; i += 1 )) ; do for (( i = $1 + 1 ; i <= $#arg ; i += 1 )) ; do
(( j = i + start_pos - 1 )) (( j = i + start_pos - 1 ))
(( k = j + 1 )) (( k = j + 1 ))
case "$arg[$i]" in case "$arg[$i]" in
@@ -1167,7 +1214,7 @@ _zsh_highlight_main_highlighter_highlight_double_quote()
breaks+=( $last_break $(( start_pos + i - 1 )) ) breaks+=( $last_break $(( start_pos + i - 1 )) )
(( i += 2 )) (( i += 2 ))
saved_reply=($reply) saved_reply=($reply)
_zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,end_pos] _zsh_highlight_main_highlighter_highlight_list $(( start_pos + i - 1 )) S $has_end $arg[i,-1]
ret=$? ret=$?
(( i += REPLY )) (( i += REPLY ))
last_break=$(( start_pos + i )) last_break=$(( start_pos + i ))
@@ -1233,13 +1280,13 @@ _zsh_highlight_main_highlighter_highlight_dollar_quote()
integer c integer c
reply=() reply=()
for (( i = $1 + 2 ; i <= end_pos - start_pos ; i += 1 )) ; do for (( i = $1 + 2 ; i <= $#arg ; i += 1 )) ; do
(( 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;;
"\\") style=back-dollar-quoted-argument "\\") style=back-dollar-quoted-argument
for (( c = i + 1 ; c <= end_pos - start_pos ; c += 1 )); do for (( c = i + 1 ; c <= $#arg ; c += 1 )); do
[[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break [[ "$arg[$c]" != ([0-9xXuUa-fA-F]) ]] && break
done done
AA=$arg[$i+1,$c-1] AA=$arg[$i+1,$c-1]
@@ -1294,7 +1341,7 @@ _zsh_highlight_main_highlighter_highlight_backtick()
last=$(( arg1 + 1 )) last=$(( arg1 + 1 ))
# Remove one layer of backslashes and find the end # Remove one layer of backslashes and find the end
while i=$arg[(ib:i+1:)[\\\\\`]]; do # find the next \ or ` while i=$arg[(ib:i+1:)[\\\\\`]]; do # find the next \ or `
if (( i > end_pos - start_pos )); then if (( i > $#arg )); then
buf=$buf$arg[last,i] buf=$buf$arg[last,i]
offsets[i-arg1-offset]='' # So we never index past the end offsets[i-arg1-offset]='' # So we never index past the end
(( i-- )) (( i-- ))
@@ -1378,4 +1425,4 @@ else
# Make sure the cache is unset # Make sure the cache is unset
unset _zsh_highlight_main__command_type_cache unset _zsh_highlight_main__command_type_cache
fi fi
typeset -ga X_ZSH_HIGHLIGHT_DIRS_BLACKLIST typeset -ga ZSH_HIGHLIGHT_DIRS_BLACKLIST

View File

@@ -0,0 +1,35 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2015 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias foo="echo hello world"
BUFFER="foo"
expected_region_highlight+=(
"1 3 alias" # foo
)

View File

@@ -0,0 +1,37 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
# Alias must be at least 4 characters to test the regression
# cf. 139ea2b189819c43cc251825981c116959b15cc3
alias foobar='echo "$(echo foobar)"'
BUFFER='foobar'
expected_region_highlight=(
"1 6 alias" # foobar
)

View File

@@ -0,0 +1,36 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias ls='command ls'
BUFFER='ls'
expected_region_highlight=(
"1 2 alias" # ls
)

View File

@@ -0,0 +1,36 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2019 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias ls=tmp tmp='command ls'
BUFFER='ls'
expected_region_highlight=(
"1 2 alias 'issue #652'" # ls
)

View File

@@ -0,0 +1,35 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2015 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
alias ls="ls"
BUFFER="ls"
expected_region_highlight+=(
"1 2 alias" # ls
)

View File

@@ -0,0 +1,34 @@
# -------------------------------------------------------------------------------------------------
# Copyright (c) 2018 zsh-syntax-highlighting contributors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted
# provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list of conditions
# and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice, this list of
# conditions and the following disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
# may be used to endorse or promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -------------------------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# -------------------------------------------------------------------------------------------------
BUFFER=$'\\'
expected_region_highlight=(
'1 1 unknown-token' # \\
)

View File

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

View File

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

View 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"
)

View File

@@ -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' # )
)

View 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
)

View 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
)

View 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
)

View File

@@ -28,6 +28,9 @@
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Define default styles.
: ${ZSH_HIGHLIGHT_STYLES[root]:=standout}
# Whether the root highlighter should be called or not. # Whether the root highlighter should be called or not.
_zsh_highlight_highlighter_root_predicate() _zsh_highlight_highlighter_root_predicate()
{ {

View File

@@ -9,7 +9,7 @@
`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`; - 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 -m "Tag version $(<.version)"`; Tag it using `git tag -s -m "Tag 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`

View File

@@ -55,15 +55,15 @@ _zsh_highlight_add_highlight()
# Copyright block # Copyright block
year="`LC_ALL=C date +%Y`" year="`LC_ALL=C date +%Y`"
if ! read -q "?Set copyright year to $year? "; then if ! { read -q "?Set copyright year to $year? " } always { echo "" }; then
year="YYYY" year="YYYY"
fi fi
exec >$fname <$0 sed -n -e '1,/^$/p' | sed -e "s/2[0-9][0-9][0-9]/${year}/" > $fname
<$0 sed -n -e '1,/^$/p' | sed -e "s/2[0-9][0-9][0-9]/${year}/"
# Assumes stdout is line-buffered # Assumes stdout is line-buffered
git add -- $fname git add -- $fname
# Buffer # Buffer
exec > >(tee -a $fname)
print -n 'BUFFER=' print -n 'BUFFER='
if [[ $buffer != (#s)[$'\t -~']#(#e) ]]; then if [[ $buffer != (#s)[$'\t -~']#(#e) ]]; then
print -r -- ${(qqqq)buffer} print -r -- ${(qqqq)buffer}

View File

@@ -1,50 +0,0 @@
# brackets
ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout
# cursor
ZSH_HIGHLIGHT_STYLES[cursor]=standout
# line
ZSH_HIGHLIGHT_STYLES[line]=
# main
ZSH_HIGHLIGHT_STYLES[default]=none
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=yellow
ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[commandseparator]=none
ZSH_HIGHLIGHT_STYLES[path]=underline
ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue
ZSH_HIGHLIGHT_STYLES[command-substitution]=none
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[process-substitution]=none
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=none
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=none
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=cyan
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=cyan
ZSH_HIGHLIGHT_STYLES[assign]=none
ZSH_HIGHLIGHT_STYLES[redirection]=none
ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
ZSH_HIGHLIGHT_STYLES[named-fd]=none
ZSH_HIGHLIGHT_STYLES[arg0]=fg=green
# root
ZSH_HIGHLIGHT_STYLES[root]=standout

View File

@@ -1,2 +0,0 @@
ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold

View File

@@ -157,24 +157,25 @@ _zsh_highlight()
# Re-apply zle_highlight settings # Re-apply zle_highlight settings
# region # region
if (( REGION_ACTIVE == 1 )); then () {
_zsh_highlight_apply_zle_highlight region standout "$MARK" "$CURSOR" (( REGION_ACTIVE )) || return
elif (( REGION_ACTIVE == 2 )); then integer min max
() { if (( MARK > CURSOR )) ; then
min=$CURSOR max=$MARK
else
min=$MARK max=$CURSOR
fi
if (( REGION_ACTIVE == 1 )); then
[[ $KEYMAP = vicmd ]] && (( max++ ))
elif (( REGION_ACTIVE == 2 )); then
local needle=$'\n' local needle=$'\n'
integer min max
if (( MARK > CURSOR )) ; then
min=$CURSOR max=$MARK
else
min=$MARK max=$CURSOR
fi
# CURSOR and MARK are 0 indexed between letters like region_highlight # CURSOR and MARK are 0 indexed between letters like region_highlight
# Do not include the newline in the highlight # Do not include the newline in the highlight
(( min = ${BUFFER[(Ib:min:)$needle]} )) (( min = ${BUFFER[(Ib:min:)$needle]} ))
(( max = ${BUFFER[(ib:max:)$needle]} - 1 )) (( max = ${BUFFER[(ib:max:)$needle]} - 1 ))
_zsh_highlight_apply_zle_highlight region standout "$min" "$max" fi
} _zsh_highlight_apply_zle_highlight region standout "$min" "$max"
fi }
# yank / paste (zsh-5.1.1 and newer) # yank / paste (zsh-5.1.1 and newer)
(( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END" (( $+YANK_ACTIVE )) && (( YANK_ACTIVE )) && _zsh_highlight_apply_zle_highlight paste standout "$YANK_START" "$YANK_END"
@@ -399,24 +400,6 @@ _zsh_highlight_load_highlighters()
} }
# Load theme
# $1 should be a theme defined in themes/ or an absolute path
_zsh_highlight_load_theme()
{
local theme=$1
shift 1
if [[ ${theme[1]} == / ]]; then
source $theme
elif [[ $theme == */* ]]; then
print -r -- >&2 "zsh-syntax-highlighting: failed on invalid theme name: ${(qq)theme}"
return 1
else
for theme in ${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:h}/themes/$theme(N) $ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR/$^ZSH_HIGHLIGHT_HIGHLIGHTERS/$theme(N); do
source $theme
done
fi
}
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
# Setup # Setup
# ------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------
@@ -428,7 +411,7 @@ _zsh_highlight_bind_widgets || {
} }
# Resolve highlighters directory location. # Resolve highlighters directory location.
_zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:=${${0:A}:h}/highlighters}" || { _zsh_highlight_load_highlighters "${ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR:-${${0:A}:h}/highlighters}" || {
print -r -- >&2 'zsh-syntax-highlighting: failed loading highlighters, exiting.' print -r -- >&2 'zsh-syntax-highlighting: failed loading highlighters, exiting.'
return 1 return 1
} }
@@ -450,8 +433,11 @@ zmodload zsh/parameter 2>/dev/null || true
# Initialize the array of active highlighters if needed. # Initialize the array of active highlighters if needed.
[[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main) [[ $#ZSH_HIGHLIGHT_HIGHLIGHTERS -eq 0 ]] && ZSH_HIGHLIGHT_HIGHLIGHTERS=(main)
# Load the theme. if (( $+X_ZSH_HIGHLIGHT_DIRS_BLACKLIST )); then
_zsh_highlight_load_theme "${ZSH_HIGHLIGHT_THEME-default}" print >&2 'zsh-syntax-highlighting: X_ZSH_HIGHLIGHT_DIRS_BLACKLIST is deprecated. Please use ZSH_HIGHLIGHT_DIRS_BLACKLIST.'
ZSH_HIGHLIGHT_DIRS_BLACKLIST=($X_ZSH_HIGHLIGHT_DIRS_BLACKLIST)
unset X_ZSH_HIGHLIGHT_DIRS_BLACKLIST
fi
# Restore the aliases we unned # Restore the aliases we unned
eval "$zsh_highlight__aliases" eval "$zsh_highlight__aliases"