Commit Graph

837 Commits

Author SHA1 Message Date
Daniel Shahaf
295d62ec88 driver: Followup to last: make the value more unique.
Part of issue #305.
2016-08-12 09:43:54 +00:00
Daniel Shahaf
d711563fe1 driver: Make it reentrant.
This fixes an infinite recursion in zsh without zle-line-pre-redraw [≤5.2] in
the following situation:

% source zsh-syntax-highlighting.zsh
% eval "my-self-insert() { zle -M 'foobar'; ${(q)widgets[self-insert]#*:} \"\$@\" }"
% zle -N self-insert my-self-insert
% source zsh-syntax-highlighting.zsh

Fixes #305.
2016-08-12 09:19:36 +00:00
Daniel Shahaf
e2f863c151 minor: Fix typo in development usage message. 2016-08-12 09:19:36 +00:00
m0viefreak
4ad311ec0a driver: Enable highlighting during isearch under zsh≥5.3.
This patch causes a behaviour difference in the [i257] scenario:

- Before this change, the zle_highlight[isearch] is applied and z-sy-h's
  highlighting isn't.

- With this change, both zle_highlight[isearch] and z-sy-h's
  highlighting are applied, so «echo foo» renders the first word in green
  underline (fg=green from ZSH_HIGHLIGHT_STYLES[builtin], underline from
  zle_highlight[isearch]).

This patch causes the presuppositional FAQ entry added in
a8fe22d422 to be correct.

This is part of #261, of which #288 was a spin-off.

[i257] https://github.com/zsh-users/zsh-syntax-highlighting/pull/257#issuecomment-168394665
2016-07-30 20:08:12 +00:00
Daniel Shahaf
171a4eec2d Merge remote-tracking branch 'danielsh/m0vie-i288-v2' (revised version of upstream/pr/288)
* danielsh/m0vie-i288-v2:
  driver: Don't highlight in isearch
  driver: Always bind zle-line-finish and use it instead of accept-*
  driver: Widget binding: Support binding incomplete/nonexistent widgets
2016-07-29 21:09:31 +00:00
m0viefreak
a8fe22d422 driver: Don't highlight in isearch
zsh version 5.2 and lower don't support ISEARCHMATCH_ACTIVE and
we are unable to re-apply zle_highlight on top. Therefore it is
impossible to see the underlined matched area.

Since that information is more important, completely disable
highlighting in isearch in that case.

To do that, we need to make sure we are actually called when
something changes in isearch.

Trumps #257.

The FAQ entry presupposes #245 will be fixed (in time for the release) too.
2016-07-29 21:07:48 +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
m0viefreak
9e569bb0fe driver: Widget binding: Support binding incomplete/nonexistent widgets 2016-07-29 20:41:06 +00:00
Daniel Shahaf
add6825898 dev tools: Extend tests/generate.zsh. 2016-07-29 19:02:40 +00:00
Daniel Shahaf
8013dc3b8d dev tools: Add a script that generates a test-data file. 2016-07-29 18:58:37 +00:00
Daniel Shahaf
fa57633d81 'main': Enable test for issue #238. 2016-07-28 08:14:23 +00:00
Daniel Shahaf
0d41933c61 'main': Add test for issue #343, concerning the 'command' precommand. 2016-07-28 07:54:28 +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
6b69389bd9 'main': New test, related to issue #328.
The test passes so I'm adding it directly to master.
2016-07-22 15:52:43 +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
Daniel Shahaf
95f7206a93 tests: Add an XFail test for issue #342. 2016-07-20 02:00:28 +00:00
Daniel Shahaf
fffe13a8fb docs: Minor tweak.
Suggested-by: Matthew Martin
2016-07-18 04:27:54 +00:00
Daniel Shahaf
80148f6c84 docs: State highlighters' designated namespace. 2016-07-12 07:05:37 +00:00
Daniel Shahaf
ba16cf2fb2 docs: s/myhighlighter/acme/g
Makes the text easier to read ("_zsh_highlight_myhighlighter_highlighter" is
a mouthful).
2016-07-12 07:03:18 +00:00
Daniel Shahaf
3e59ab41b6 driver: Change a variable name to avoid squatting the highlighters' namespace.
Part of issue #329.
2016-07-12 06:50:49 +00:00
Daniel Shahaf
d13da0cf00 'main': Support vi linewise region (REGION_ACTIVE == 2).
Merge remote-tracking branch 'danielshahaf/i267-linewise-region-v1'

* danielsh/i267-linewise-region-v1:
  tests: Add a regression test for issue #267, concerning highlighting a vi linewise region.
  Support linewise region.
2016-07-01 02:00:10 +00:00
Daniel Shahaf
ee07588cfd tests: Add a regression test for issue #267, concerning highlighting a vi linewise region. 2016-07-01 01:59:37 +00:00
m0viefreak
b9112aec79 driver: Widget binding: Use ${(k)widgets} instead of $(zle -la)
Avoids a fork.
2016-06-20 18:37:11 +00:00
m0viefreak
f3d3aaa00c 'main': Document _pathseparator styles 2016-06-12 09:06:30 +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
750aebc553 driver: Stop requiring function_argzero.
Instead, use the %N prompt expando, as suggested by Bart in users/21637.

Avoid the `print -P %N` syntax to save a fork on Cygwin, at the expense
of not supporting zsh's from 2001 through c. 2004 vintages.

Fixes #338.
2016-06-10 15:18:46 +00: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
10a596f9fd dev docs: Document a useful tab completion setting. 2016-06-03 08:46:30 +00:00
Daniel Shahaf
4b77af73fb minor: Fix typo in comment.
Two instances.
2016-06-03 08:41:45 +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
fccf92402b minor: tests: Formatting tweak to XPASS output.
Remove superfluous single quotes around the second hyphen.
2016-06-03 03:57:45 +00:00
Daniel Shahaf
29b30e0ca7 'main': Add XFail test for issue #330, concerning command word after array assignment. 2016-06-03 03:42:12 +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
Daniel Shahaf
14711a51f3 tests: Explicitly test 'default' style inside an array assignment. 2016-06-03 02:41:10 +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
6362c757b6 tests: Extend issue #290 test with another variant.
The test being extended is highlighters/main/test-data/control-flow2.zsh.
2016-05-13 04:28:43 +00:00
Matthew Martin
d37c55c788 minor: tests: Add comment for NONE in expected_region_highlight 2016-05-12 22:59:06 -05:00
Matthew Martin
364f206a54 docs: Give example of test that modifies its environment 2016-05-12 22:48:07 -05:00
Matthew Martin
19acd8e844 docs: Mention $BUFFER 2016-05-12 22:48:03 -05:00
Matthew Martin
13018f3dd7 docs: Document use of NONE in expected_region_highlight 2016-05-12 22:47:55 -05:00