Commit graph

218 commits

Author SHA1 Message Date
Matthew Martin
91fa057a39 minor: 'main': Only search for prefixes if :h is a directory 2016-06-01 00:54:30 -05:00
Daniel Shahaf
f060622dc6 'main': Internal cleanup: drop $style_override.
Merge remote-tracking branch 'upstream/pr/326'

* upstream/pr/326:
  'main': Internal cleanup: drop $style_override.

Conflicts:
	highlighters/main/main-highlighter.zsh (context lines only)
2016-06-01 05:45:39 +00:00
m0viefreak
6cd39e7c70 'main': Highlight path separators
This commit is based on the work done by
Jorge Israel Peña (blaenk) in #136.

Changes:
* Adjusted to changes on the latest master branch.
* Use regular path highlighter colors by default.
* Break out early if the separator color is the same to
  improve performance.
* Tests.
2016-05-31 15:06:12 +00:00
Daniel Shahaf
a5b8bc0ef0 'main': Internal cleanup: drop $style_override.
Changes the interface of _zsh_highlight_main_highlighter_check_path().

Suggested-by: m0viefreak
2016-05-27 10:21:28 +00:00
m0viefreak
3b67e656bf 'main': Implement simple command type cache 2016-05-24 23:08:11 +02:00
m0viefreak
12b879caf7 'main': Use zsh/parameter instead of type -w
If possible, try to use the zsh/parameter module to get
information about a shell words.

This avoids subshells and is a huge speed improvement
on systems such as cygwin.

Note 1:
$commands does not know about PATH_DIRS. So in case
PATH_DIRS is set, 'type -w' is still used if nothing
else matches.

Note 2:
zsh/parameter can't distinguish between 'command' and
'hashed'. Adjusted the test for that case to XFAIL.

The ideal solution would be if whence had an option to
put the result in REPLY instead of printing it to stdout.
2016-05-13 20:25:07 +02:00
m0viefreak
61f43255ab 'main': Support multiple styles in _zsh_highlight_main_add_region_highlight 2016-05-13 20:25:04 +02:00
Daniel Shahaf
f146651913 Merge part of PR #298
* commit '2f18ba':
  'main': use zsh/parameter to resolve alias
  driver: load zsh/parameter if available
2016-05-13 02:27:29 +00:00
m0viefreak
2f18ba64e3 'main': use zsh/parameter to resolve alias
If possible, use zsh/parameter to avoid forks.

Fixes #263.
2016-05-13 02:27:03 +00:00
Daniel Shahaf
def8c0da83 Bump copyright years. 2016-05-13 01:29:49 +00:00
Daniel Shahaf
4f5bb6cf96 Merge remote-tracking branch 'upstream/pr/308' into HEAD
* upstream/pr/308:
  'main': Fix issue #302, "Process substitution misparsed as redirection".
  'main': Factor out common code.  No functional change.
  'main': Add a regression test for issue #302, "Process substitution misparsed as redirection".
2016-05-13 01:24:01 +00:00
Daniel Shahaf
7b82b88a71 'main': Don't leak the PATH_DIRS options.
Found-by: m0viefreak
(in #298)
2016-05-12 19:24:00 +00:00
Sebastian Gniazdowski
ef4bfe5bcc 'main': 2nd optimization that in my tests shows 2.2s -> 2.0s 2016-05-12 19:22:29 +00:00
Daniel Shahaf
5a98cd3a10 Merge remote-tracking branch 'upstream/pr/315' into HEAD
* upstream/pr/315:
  'main': optimization that in my tests shows 2.7s -> 2.2s
2016-05-12 18:30:50 +00:00
Sebastian Gniazdowski
02229ebd63 'main': optimization that in my tests shows 2.7s -> 2.2s
Consider indexing long buffers (say 300 chars). E.g. following line:
      integer offset=${${buf[start_pos+1,len]}[(i)$needle]}
will gradually go into large indices for first index [a,] and be kept
at large index for second index [,b]. Instead, we can remove already
processed characters from buf:
    proc_buf="${proc_buf[offset + $#arg + 1,-1]}"
$offset and $#arg are small, first index will not be large. $proc_buf
will be smaller and smaller and the second index [,-1] will run shorter
and shorter.
2016-05-12 18:29:09 +00:00
Daniel Shahaf
62f1c108f3 tests: New test to capture off-by-ones.
Inspired by #312.
2016-05-11 20:36:18 +00:00
Daniel Shahaf
fc9c892a3f 'main': Fix issue #302, "Process substitution misparsed as redirection". 2016-05-09 03:29:27 +00:00
Daniel Shahaf
bfabffbf97 'main': Factor out common code. No functional change. 2016-05-09 03:26:29 +00:00
Daniel Shahaf
6889ff6bd2 'main': Add a regression test for issue #302, "Process substitution misparsed as redirection". 2016-05-09 03:26:06 +00:00
Matthew Martin
d3678ec7a8 tests: Remove unused_highlight 2016-05-05 12:28:43 -05:00
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.
2016-04-29 10:09:16 -05:00
Matthew Martin
089329660b highlighters: Pass around the style key instead of the style itself 2016-04-29 09:53:05 -05:00
Matthew Martin
a830613467 tests: Specify the style key instead of the style itself 2016-04-29 09:51:13 -05:00
Matthew Martin
78290e043b tests: Expect the correct style 2016-04-03 20:43:13 -05:00
Matthew Martin
31ac2b36a9 tests: Quote style in expected_region_highlight 2016-04-02 09:45:24 -05:00
Daniel Shahaf
bc7f8ea433 'main': Restore support for zsh-4.3.10 and older.
zsh older than workers/28418 (zsh revision 23bdfc7fd2a012d5205ed22d18eb39e41c8fbc95)
doesn't support the «${name:offset:length}» syntax.  Therefore, use the older
«$name[start,end]» syntax instead.

Followup to 3cb58fd7d7, "Optimization: -1 is
extra computation of string length internally".

Fixes zsh-users/zsh-syntax-highlighting#279.
2016-03-23 01:32:44 +00:00
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).
2016-03-13 02:47:25 +00:00
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
2016-02-14 17:34:53 +02:00
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
2016-02-12 08:31:14 +01:00
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.
2016-01-20 22:10:49 +00:00
Daniel Shahaf
28932316cc aliases: Highlight aliases with '=' in their LHS as error. (Part of issue #263.) 2016-01-11 15:27:48 +00:00
Daniel Shahaf
5e4b446dee aliases: Add a test for one variant of issue #263. 2016-01-11 15:07:18 +00:00
Daniel Shahaf
4f3910cbba Fix issue #248: Highlight 'pkexec' as a precommand. 2015-12-04 23:40:30 +00:00
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.
2015-11-29 03:16:01 +00:00
Daniel Shahaf
48ecd29180 tests: Add two XFail tests for issue #238, "fd redirections at command word". 2015-11-29 03:15:55 +00:00
Daniel Shahaf
430cf55368 tests: Cover [default]. 2015-11-29 02:56:07 +00:00
Daniel Shahaf
46cd970bc4 tests: Improve tests by using $unused_highlight.
The default for [redirection] is 'none', so it wasn't actually being tested.
2015-11-29 02:53:58 +00:00
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.
2015-11-29 02:02:42 +00:00
Matthew Martin
8e115052e9 docs: Fix broken symlinks 2015-11-24 00:40:09 -06:00
Matthew Martin
0ab450ae47 docs: Move docs into docs/ 2015-11-24 00:09:21 -06:00
Matthew Martin
35e0b0ca69 docs: Remove duplicate 'How to activate it' sections 2015-11-24 00:09:21 -06:00
Matthew Martin
2dd6923c30 docs: Move highlighter headers down one level 2015-11-24 00:09:21 -06:00
Daniel Shahaf
3f163a2fd4 docs copyedit: Rewrap to 80 columns, part 2. 2015-11-24 06:06:16 +00:00
Daniel Shahaf
8ea392e361 docs copyedit: Restyle bold-italic to fixed-width. 2015-11-24 06:06:16 +00:00
Daniel Shahaf
6c033e62e9 docs copyedit: Whitespace. 2015-11-24 06:06:16 +00:00
Daniel Shahaf
17fbcad8ac 'main': Fix state check.
At this time, no user-visible consequences are known.
2015-11-18 16:37:38 +00:00
Daniel Shahaf
29fd6ec1de Support the '|&', '&!', '&|' command separators. 2015-11-17 20:19:19 +00:00
Daniel Shahaf
3ed0f7f823 noop: Consolidate two identical conditionals. 2015-11-17 20:07:14 +00:00
Daniel Shahaf
2dbcb575e5 internal: Document the ':regular' state. 2015-11-17 19:40:58 +00:00
Daniel Shahaf
00de155063 docs: 'main': Improve styles documentation. 2015-11-17 18:41:14 +00:00