Commit graph

186 commits

Author SHA1 Message Date
Daniel Shahaf
fed37a90ac 'main': Fix a bug concerning command word with embedded colon-space sequences.
Such a command word would, if not valid, fall through to the `type -w` case,
where the output would be misparsed, consequently the forward-compatible [arg0]
style would be used.
2016-11-02 03:16:45 +00:00
Daniel Shahaf
28d7056a7a 'main': Escape '!' within double-quoted strings. 2016-10-19 23:56:25 +00:00
Daniel Shahaf
7d38d07255 'main': Followup to fdaeec4514: Update comment.
That revision was itself a followup to 51614ca2c9.
2016-10-17 20:46:46 +00:00
Daniel Shahaf
094329eb14 'main': Introduce style fallback for the command word.
Fixes #316.

* danielsh/i316-v2:
  'main': Enable fallback to the 'arg0' style.
  'main': Set fallback style for the 'arg0' style.
2016-09-28 13:25:05 +00:00
Daniel Shahaf
bccc3dc269 'main': Enable fallback to the 'arg0' style. 2016-09-28 13:22:29 +00:00
Daniel Shahaf
b4537a972e 'main': Set fallback style for the 'arg0' style.
The fallback style name uses '_' in anticipation of a future auto-fallback
feature keyed on style names.

'arg0' was previously known as 'commandtypefromthefuture'.
2016-09-28 13:22:09 +00:00
Daniel Shahaf
dd51b7bebe Merge remote-tracking branch 'upstream/pr/374' into HEAD
* upstream/pr/374:
  'main': Directly count spaces to skip, don't leverage proc_buf length
2016-09-25 15:58:35 +00:00
Sebastian Gniazdowski
15461e7d21 'main': Directly count spaces to skip, don't leverage proc_buf length
Main highlighter run on itself, on the optimized version:

- optimized (8 runs, 3 last noted):
1.1201650000
1.1074430000
1.1263810000

- unoptimized (8 runs, 3 last noted):
1.5746400000
1.5115250000
1.5155440000

Average difference: 0.415907
2016-09-25 17:52:56 +02:00
Daniel Shahaf
44ef6e38e5 'main': Highlight several more special (non-alphabetic) parameters. 2016-09-25 14:51:02 +00:00
Daniel Shahaf
4afe670f7a 'main': Highlight shell's PID ($$) inside double quotes. 2016-09-25 14:40:58 +00:00
Daniel Shahaf
c3913e0d8e 'main': Highlight command substitutions inside double quotes.
Part of issue #139.
2016-09-25 14:40:02 +00:00
Daniel Shahaf
4fc35362ee 'main': Permit subshells to end at command position.
Fixes #344.
2016-09-25 12:06:39 +00:00
Daniel Shahaf
2bb8f0703d 'main': Highlight mismatched foreach/end.
Fixes #96.
2016-09-25 11:52:15 +00:00
Daniel Shahaf
b2733a64da 'main': Highlight mismatched do/done. 2016-09-25 11:38:54 +00:00
Sebastian Gniazdowski
c6b6513ac0 'main' / *_check_path: Precompute $#BUFFER and use it for speed gain
Running main highlighter on itself (both runs are on the optimized
version):

- clean (8 runs, last 3 noted):
1.7007670000
1.7330720000
1.7038810000

- optimized (8 runs, last 3 noted):
1.5007230000
1.5142960000
1.4973320000

Average difference: 0.208456

When parsing main-highlighter with itself, the *_check_path function is
called 426 times. Note that there are 686 region_highlight resulting
entries.
2016-09-25 12:35:28 +02:00
Daniel Shahaf
e5782e4ddf 'main': Highlight 'always' blocks.
Fixes #335.
2016-09-25 08:11:01 +00:00
Daniel Shahaf
8bf423d16d 'main': Don't find command positions within multiline array literals.
Fixes #333.
2016-09-24 17:55:18 +00:00
Daniel Shahaf
a4196eda5e 'main': Restore compatibility with zsh-4.3.14 and older (after e3182c18de8f).
Fixes #368.
2016-09-23 15:55:06 +00:00
Daniel Shahaf
6f91850a01 'main': Highlight first command word in named functions defined in the sh syntax when MULTI_FUNC_DEF is set.
Fixes a subset of issue #237.
2016-09-23 06:37:26 +00:00
Daniel Shahaf
51b9d79c3b 'main': Highlight mismatched parentheses and braces. 2016-09-22 11:12:42 +00:00
Daniel Shahaf
02807f1826 'main': Support the IGNORE_BRACES option.
This is related to a future "unbalanced { ( ) }" check for issue #344.
2016-09-22 03:45:04 +00:00
Daniel Shahaf
fdaeec4514 'main': Followup to 51614ca2c9: Run cheaper conditions first.
This was suggested on #355.
2016-09-08 19:09:29 +00:00
Daniel Shahaf
51614ca2c9 'main': Avoid triggering a zsh bug related to hashed commands.
This manifested in completion of the form «./foo<TAB>» where there happened to
be a program called 'foo' in $PATH.

Fixes #354.
Closes #355.
2016-08-30 02:56:23 +00:00
Daniel Shahaf
c7f7d2ff16 *: Change highlighters' namespace.
Fixes #329.

Merge remote-tracking branch 'danielsh/i329-v1'

* danielsh/i329-v1:
  highlighters: Rename entry points.
  driver: Rename highlighter entry points
2016-08-16 17:53:01 +00:00
Daniel Shahaf
c793e0dcea highlighters: Rename entry points.
This tracks the API change made in the previous commit, as suggested in the
(#if 0'd) deprecation warning.
2016-08-16 17:51:43 +00:00
Daniel Shahaf
2c002f9f89 noop: Add comments. 2016-08-16 13:40:31 +00:00
Daniel Shahaf
757d047f09 'main': The word after 'sudo' is only a non-command word if it is an option. 2016-08-16 13:31:05 +00:00
Daniel Shahaf
179b8e753f 'main': Test for redirection earlier.
This is a prerequisite for the next commit.

The incumbent code was wrong: the test of $in_redirection in the first hunk
would never have seen «(( in_redirection == 2 ))».  That had no visible
effect since options to sudo don't look like redirection operators.
2016-08-16 13:27:36 +00:00
Daniel Shahaf
6e2ef574c8 noop: Restructure code for clarity.
The structure now mirrors the stall construct at the top of the loop.
2016-08-16 13:25:43 +00:00
Daniel Shahaf
d1c773faa7 noop: Fix indentation. 2016-08-16 13:00:55 +00:00
m0viefreak
5bae621900 driver: Always bind zle-line-finish and use it instead of accept-*
Special handling for cursor imprint or partial path highlighting
is needed in more cases than accept-*. For example when accepting
a line from isearch, no accept-* widget is invoked.

The proper way is to use zle-line-finish.

Trumps #259.
Fixes #284.
2016-07-29 20:41:06 +00:00
Daniel Shahaf
e6fb61c42b 'main': Highlight a broken symlink as a file.
Merge remote-tracking branch 'upstream/pr/342'

* upstream/pr/342:
  'main': Highlight a broken symlink as a file.
  tests: Add an XFail test for issue #342.
2016-07-22 16:09:06 +00:00
Daniel Shahaf
3409a2e4d2 *: s/echo/print/
Just in case one of the interpolated variables contains a backslash.
2016-07-21 04:01:50 +00:00
Daniel Shahaf
53083da821 'main': Highlight a broken symlink as a file.
Fixes #342.
2016-07-20 02:01:15 +00:00
m0viefreak
9a934d291e 'main': Path separators: Leave styles empty by default
If the separator feature is disabled, this makes it possible to
change the main 'path' styles in a running session without the
need to touch the '_pathseparator' styles, too.
2016-06-11 14:19:17 +02:00
Daniel Shahaf
d9e07b5082 'main': simple parameter expansions at command word: Don't use an undefined value.
Causes such expansions to be highlighted as [unknown-token] rather than as default (absent from $region_highlight).

Fixes #337.
2016-06-10 14:31:57 +00:00
Daniel Shahaf
da91264122 'main': Add missing arguments.
Part of #337.
2016-06-10 14:31:57 +00:00
Daniel Shahaf
e35a0b256e 'main': Try the "non-command word" codepath when a word may be either a command word or a non-command word.
Merge remote-tracking branch 'upstream/pr/331'

* upstream/pr/331:
  'main': Try the "non-command word" codepath when a word may be either a command word or a non-command word.
2016-06-05 16:58:12 +00:00
Daniel Shahaf
47144ad974 'main': Fix issue #290, «Mishighlights "longloops" 'repeat'».
* upstream/pr/319:
  tests: Extend issue #290 test with another variant.
  'main': Fix issue #290, «Mishighlights "longloops" 'repeat'».
  tests: New test for issue #290, «Mishighlights "longloops" 'repeat'».
2016-06-03 04:32:25 +00:00
Daniel Shahaf
7fb6f99791 'main': Try the "non-command word" codepath when a word may be either a command word or a non-command word.
Fixes #231.
Fixes #330.
2016-06-03 04:25:00 +00:00
Daniel Shahaf
f4036a09ce 'main': Highlight scalar assignments to argv
Assignments to positional parameters using scalar assignment syntax is
a feature: it is covered by upstream's test suite ("append to positional
parameter" in Test/A06assign.ztst).
2016-06-03 03:27:52 +00:00
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
ef68f50c04 'main': Fix issue #290, «Mishighlights "longloops" 'repeat'». 2016-05-13 03:30:11 +00: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