Daniel Shahaf
62f1c108f3
tests: New test to capture off-by-ones.
Inspired by #312 .
8 роки тому
m0viefreak
5fe8fd8bdc
'brackets': Fix for one-based indexing
Use correct indexing also for cursor-matchingbracket.
Fixup for 95d82568d8
8 роки тому
Matthew Martin
b5955213b9
tests: Add tests for 'brackets' and 'pattern'
8 роки тому
Matthew Martin
f73f3d53d3
'brackets': Allow unset ZSH_HIGHLIGHT_STYLES
Without this when bracket_color_size is 0,
$(( (levelpos[$pos] - 1) % bracket_color_size + 1 ))
errors with division by zero.
8 роки тому
Matthew Martin
eaa4335c34
tests: Set ZSH_HIGHLIGHT_STYLES=() during tests
Since the _zsh_highlight_add_highlight that the tests use ignores
ZSH_HIGHLIGHT_STYLES, we can test both an injective mapping and an empty
mapping at once.
8 роки тому
Matthew Martin
d3678ec7a8
tests: Remove unused_highlight
8 роки тому
Matthew Martin
ccaf6f48a1
brackets: Fix bug introduced in 95d8256
8 роки тому
Matthew Martin
e05b8e88ad
'brackets': Check if brackets match on first pass
This removes the need for the typepos array.
8 роки тому
Matthew Martin
95d82568d8
'brackets': Use one-based indexing
zsh arrays start at one, and this will make the next commit easier.
8 роки тому
Matthew Martin
f4d3dcb42f
'brackets': Move highlight call outside conditional
8 роки тому
Matthew Martin
fd84010252
'brackets': Lift local declarations from inside loops
8 роки тому
Matthew Martin
4da9889d15
tests: Use 'NONE' to denote no highlighting
'none' is a valid highlighting type. Since by convention styles are all
lowercase, 'NONE' shouldn't conflict with anything.
Closes #289 .
8 роки тому
Matthew Martin
341a3ae1f0
highlighters: Use _zsh_highlight_add_highlight
_zsh_highlight_add_highlight appends to region_highlight $1 $2 and the
next non-null parameter. If there is no non-null parameter, do nothing,
This is so that highlighters can add a style with fallbacks if the most
specific style is not defined. If none of the applicable styles are
defined, do the right thing and don't add an invalid entry to
region_highlight.
The pattern highlighter doesn't use this function as it'd need too large
of an API change.
8 роки тому
Matthew Martin
089329660b
highlighters: Pass around the style key instead of the style itself
8 роки тому
Matthew Martin
a830613467
tests: Specify the style key instead of the style itself
8 роки тому
m0viefreak
38c8fbea2d
root-highlighter: use EUID instead of id -u command
No need to fork every time.
8 роки тому
Daniel Shahaf
b52a485c5c
brackets: Optimize a tiny bit.
Compute «${#BUFFER}» just once. I haven't measured the effect of this, but
it might just avoid a strlen() every time around the loop, which could add
up for large ${BUFFER}s.
See issue #295 .
8 роки тому
Matthew Martin
78290e043b
tests: Expect the correct style
8 роки тому
Matthew Martin
31ac2b36a9
tests: Quote style in expected_region_highlight
8 роки тому
Daniel Shahaf
bc7f8ea433
'main': Restore support for zsh-4.3.10 and older.
zsh older than workers/28418 (zsh revision 23bdfc7fd2
)
doesn't support the «${name:offset:length}» syntax. Therefore, use the older
«$name[start,end]» syntax instead.
Followup to 3cb58fd7d7b9e42067ffcf24892114dc2c9b26e4, "Optimization: -1 is
extra computation of string length internally".
Fixes zsh-users/zsh-syntax-highlighting#279 .
8 роки тому
Daniel Shahaf
4c23a2fd1b
'main': Highlight lone '!' correctly: it's not a history expansion.
While here, also add a test for the '!' reserved word (which is highlighted
since c216242b
).
8 роки тому
Daniel Shahaf
e500ca2462
'main': Don't highlight in vared
This is a continuation of 451665cb2a
which did
the same for the $PS3 prompt.
Reported-by: Sebastian Gniazdowski
8 роки тому
Sebastian Gniazdowski
3cb58fd7d7
Optimization: -1 is extra computation of string length internally
./parse.zsh "zplugin.zsh" > out_norm.txt 106,17s user 7,84s system 98% cpu 1:55,85 total
./parse.zsh "zplugin.zsh" > out_opt.txt 51,91s user 7,44s system 99% cpu 59,912 total
% wc -l zplugin.zsh
3188 zplugin.zsh
8 роки тому
Daniel Shahaf
451665cb2a
'main': Don't highlight at the $PS3 prompt.
The input to the $PS3 prompt is not commands, so the 'main' highlighter is
not applicable to it.
Fixes zsh-users/zsh-syntax-highlighting#268 .
8 роки тому
Daniel Shahaf
28932316cc
aliases: Highlight aliases with '=' in their LHS as error. (Part of issue #263.)
8 роки тому
Daniel Shahaf
5e4b446dee
aliases: Add a test for one variant of issue #263 .
8 роки тому
Daniel Shahaf
4f3910cbba
Fix issue #248 : Highlight 'pkexec' as a precommand.
8 роки тому
Daniel Shahaf
73ee7c1f6c
Fix part of issue #238 , "fd redirections at command word".
This fixes fd's specified by a (single) digit. The named fd syntax remains an XFail.
8 роки тому
Daniel Shahaf
48ecd29180
tests: Add two XFail tests for issue #238 , "fd redirections at command word".
8 роки тому
Daniel Shahaf
430cf55368
tests: Cover [default].
8 роки тому
Daniel Shahaf
46cd970bc4
tests: Improve tests by using $unused_highlight.
The default for [redirection] is 'none', so it wasn't actually being tested.
8 роки тому
Daniel Shahaf
09c4114eb9
command word: Do not attempt to interpret command separator tokens as anything else.
The important part of this change is removing the second conjunct from the
condition; the remainder of the change gives one example of when that matters.
8 роки тому
Daniel Shahaf
eb3715a56a
docs: Followup to the recent docs branch: clean up some internal cross-references.
8 роки тому
Matthew Martin
8e115052e9
docs: Fix broken symlinks
8 роки тому
Matthew Martin
0ab450ae47
docs: Move docs into docs/
8 роки тому
Matthew Martin
35e0b0ca69
docs: Remove duplicate 'How to activate it' sections
8 роки тому
Matthew Martin
2dd6923c30
docs: Move highlighter headers down one level
8 роки тому
Daniel Shahaf
6e99128987
docs copyedit: minor: Spelling/punctuation fix.
8 роки тому
Daniel Shahaf
3f163a2fd4
docs copyedit: Rewrap to 80 columns, part 2.
8 роки тому
Daniel Shahaf
9ce97cd64d
docs copyedit: minor.
8 роки тому
Daniel Shahaf
12097d55d1
docs copyedit: Rewrap to 80 columns.
8 роки тому
Daniel Shahaf
8ea392e361
docs copyedit: Restyle bold-italic to fixed-width.
8 роки тому
Daniel Shahaf
91e4a576fb
docs copyedit: Port 6d93ea07fd
to the other highlighters' README's.
8 роки тому
Daniel Shahaf
6c033e62e9
docs copyedit: Whitespace.
8 роки тому
Daniel Shahaf
17fbcad8ac
'main': Fix state check.
At this time, no user-visible consequences are known.
9 роки тому
Daniel Shahaf
29fd6ec1de
Support the '|&', '&!', '&|' command separators.
8 роки тому
Daniel Shahaf
3ed0f7f823
noop: Consolidate two identical conditionals.
8 роки тому
Daniel Shahaf
2dbcb575e5
internal: Document the ':regular' state.
8 роки тому
Daniel Shahaf
00de155063
docs: 'main': Improve styles documentation.
8 роки тому
Daniel Shahaf
7d4252f5f5
minor: docs: Improve dollar-double-quoted-argument documentation.
8 роки тому