Commit graph

200 commits

Author SHA1 Message Date
Daniel Shahaf
4fcfb15913 Highlight parameter expansions that are a command word.
Fixes zsh-users/zsh-syntax-highlighting#101.
2015-11-17 01:37:58 +00:00
Daniel Shahaf
6e3720f39d dollar-double-quoted-argument: Support the syntax «"${foo}"». (Issue #186.) 2015-11-17 00:40:02 +00:00
Daniel Shahaf
28776371a0 tests: Add an XFail test for highlighting «"${foo}"». (Issue #186.) 2015-11-17 00:37:58 +00:00
Daniel Shahaf
96ee5116b1 Fix issue #228, "Support the PATH_DIRS option". 2015-11-16 23:14:48 +00:00
Daniel Shahaf
a636527f70 tests: Add an XFail test for issue #228, "Support the PATH_DIRS option".
This builds upon the test harness auto-cleaned-up directories work (c01533920).
2015-11-16 23:04:11 +00:00
Daniel Shahaf
2b35ff1c15 minor: Rename a test file to a not-escape-needing name.
There's simply no reason to use such names, now that the filename is no longer
itself test data.
2015-11-16 22:57:47 +00:00
Daniel Shahaf
c015339202 tests: Provide an independent, auto-cleaned working directory to each test.
Fixes zsh-users/zsh-syntax-highlighting#182.
Prerequisite for testing issue #228.

* tests/test-highlighting.zsh
  (run_test): Move functionality to run_test_internal; make run_test be a wrapper
    that handles creating and cleaning up the tempdir.

* tests/README.md: Document the new feature.

* "highlighters/main/test-data/path-space- .zsh"
* highlighters/main/test-data/path-tilde-named.zsh
* highlighters/main/test-data/path.zsh
    Change test data to not depend on being run from the source directory.
2015-11-16 22:54:52 +00:00
Daniel Shahaf
3620ad951f Add an XFail test for issue #231, "Assignment terminating subshell flags closing parenthesis as an error". 2015-11-16 19:04:37 +00:00
Daniel Shahaf
b285c7b821 brackets: Highlight closing ')' of array assignments correctly. (Issue #226.)
Followup to c0dafd1d85, which changed the highlight of
those ')'s from <nothing> to [reserved-word].
2015-11-16 18:44:44 +00:00
Daniel Shahaf
c0dafd1d85 brackets: Highlight the closing brackets of subshells and blocks. (Issue #226.) 2015-10-30 20:20:30 +02:00
Daniel Shahaf
a59f442d2d brackets: Highlight the closing brackets of arithmetic expansion. (Issue #226.) 2015-10-30 17:28:48 +00:00
Daniel Shahaf
8b4adbd991 Fix issue #222, "command word after repeat". 2015-10-30 13:31:43 +00:00
Daniel Shahaf
6fbd2aa957 Add an XFail test for issue #222, "command word after repeat". 2015-10-30 13:31:23 +00:00
Daniel Shahaf
9e178f9f39 subshells: Highlight the opening parenthesis correctly. (Issue #166.)
Followup to 0d1bfbcbfa.
2015-10-30 11:38:32 +02:00
Daniel Shahaf
5a38710564 subshells: Add an XFail test demonstrating that #166 is not yet fixed.
Reported-by: Antony Lee
2015-10-30 09:34:01 +00:00
Daniel Shahaf
1ac39b0af1 comments: Mark prematurely-terminated command as an error.
This is already done for commands prematurely terminated by ";".
2015-10-30 08:38:45 +02:00
Daniel Shahaf
693de99a90 comments: Fix issue #163 and #167: Highlight comments. 2015-10-30 08:38:44 +02:00
Daniel Shahaf
e76f208cf8 comments: Add a PASSing test for the NO_INTERACTIVE_COMMENTS case. 2015-10-30 08:38:39 +02:00
Daniel Shahaf
e9ceb2017e comments: Add XFail tests from issues #163 and #167.
These tests are based on the patches contributed in those issues:

    commit 9d9df4fe80 (upstream/pr/167)
    Author:     Miciah Masters <miciah.masters@gmail.com>
    AuthorDate: Thu Apr 23 20:28:24 2015 -0400
    Commit:     Miciah Dashiel Butler Masters <mmasters@redhat.com>
    CommitDate: Thu Apr 23 20:28:24 2015 -0400

        Highlight comments

    M       highlighters/main/main-highlighter.zsh
    A       highlighters/main/test-data/comments.zsh

    commit d94f1a037f (upstream/pr/163)
    Author:     sonnym <michaud.sonny@gmail.com>
    AuthorDate: Fri Mar 6 18:27:57 2015 -0500
    Commit:     sonnym <michaud.sonny@gmail.com>
    CommitDate: Fri Mar 6 21:16:27 2015 -0500

        highlight comments when interactive_comments is on

    M       highlighters/main/main-highlighter.zsh
    A       highlighters/main/test-data/comment-embedded.zsh
    A       highlighters/main/test-data/comment-leading.zsh

Patch-by: sonnym <michaud.sonny@gmail.com>
Patch-by: Miciah Masters <miciah.masters@gmail.com>
(corrected and refreshed for harness changes by me)
2015-10-29 18:08:30 +02:00
Daniel Shahaf
2f05620b19 sudo: Flag an error when a required argument is missing. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
f49f3bf0c0 sudo: Extend tests. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
a3047a9121 sudo: Highlight an empty sudo; as an error.
The word following 'sudo' was considered :regular:, although it isn't.
2015-10-29 12:01:13 +00:00
Daniel Shahaf
86e9249709 sudo/redirections: Fix remaining part of issue #221, "sudo and redirection don't mix". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
0d1bfbcbfa Highlight subshells and anonymous functions correctly.
Fixes zsh-users/zsh-syntax-highlighting#166.
Fixes zsh-users/zsh-syntax-highlighting#194.
Builds upon the issue #207 work.
2015-10-29 12:01:13 +00:00
Daniel Shahaf
2218e26bf8 command word: Highlight 'else' correctly. Part of issue #207. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
b397b12ac1 command word: Start fixing issue #207, "Word following certain reserved words should be a command word". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
87deac3062 command word: Add an XFail test for issue #207. 2015-10-29 12:01:13 +00:00
Daniel Shahaf
01d7eeb3c7 Fix issue #205, "';' after assignment is highlighted as unknown-token". 2015-10-29 12:01:13 +00:00
Daniel Shahaf
be006aded5 sudo/redirections: Fix part of issue #221, "sudo and redirection don't mix". 2015-10-29 12:01:11 +00:00
Daniel Shahaf
c6355a31b7 Followup to last: re-fix issue #9 and add test for it.
The fix for issue #9 was accidentally broken by the penultimate commit.

Note that we don't care about aliases to ZSH_HIGHLIGHT_TOKENS_COMMANDSEPARATOR
entries, since the code deals with aliases at command position.
2015-10-29 12:01:11 +00:00
Daniel Shahaf
2c9f8c8c95 Fix issue #209, "precommand modifiers at non-command-word position". 2015-10-29 12:01:11 +00:00
Daniel Shahaf
80d692c400 command word: Add an XFail test for issue #194, "Highlight anonymous functions". 2015-10-29 12:01:11 +00:00
Daniel Shahaf
e49251b6fa sudo/redirections: Add two XFail tests for issue #221, "sudo and redirection don't mix". 2015-10-29 12:01:09 +00:00
Daniel Shahaf
59fbdda64c main: Refresh highlighting upon accept-* widgets (accept-line et al).
Use this to remove [path_prefix] highlighting during accept-* widgets.
This causes ": file.tx<CR>" to remove the underline from "file.tx", like
": file.tx<SPACE>" already does.  (Assume 'file.txt' exists.)
2015-10-28 09:24:08 +02:00
Daniel Shahaf
7723edf4f5 Add an XFail test for accept-line semantics. 2015-10-28 08:30:05 +02:00
Daniel Shahaf
feec9f58c9 Followup to last: Fix issue number in comment. 2015-10-27 13:38:40 +02:00
Daniel Shahaf
ed6d229b1c Add XFail test for issue #208, 'precommand modifiers at non-command-word position'. 2015-10-27 12:33:11 +02:00
Daniel Shahaf
9816fcf055 redirections: Test an infix redirection. 2015-10-27 05:20:24 +00:00
Daniel Shahaf
871af68082 sudo: Extend test to cover all codepaths. 2015-10-27 05:09:13 +00:00
Daniel Shahaf
98aee7f8b9 Remove path_approx.
Fixes zsh-users/zsh-syntax-highlighting#187.
Adds a test for zsh-users/zsh-syntax-highlighting#204.
2015-10-27 04:29:05 +00:00
Daniel Shahaf
20d106bd4d noop: Associate an XFAIL test with its issue. 2015-10-23 04:57:05 +00:00
Daniel Shahaf
d66113c1ed Add XFAIL test for issue #205, "';' highlighted as unknown-token". 2015-10-23 04:56:02 +00:00
Daniel Shahaf
728ed66ff9 Fix copyright year.
Followup to b2ac98b981.
2015-10-23 04:53:06 +00:00
Daniel Shahaf
11c060ab76 test harness: Fix a bug whereby 'todo' state would propagate to all subsequent test points.
Update expectations on the subshell test (which triggered this bug, since it has
a passing test point following a 'todo' test point).
2015-10-23 04:26:51 +00:00
Daniel Shahaf
b2ac98b981 Fix issue #216: test failure with HOME=/nonexistent.
Make the test pass by setting explicitly the global state (existing $HOME) it
depends on.  Test another value of the global state (a non-existing $HOME).
2015-10-23 03:51:06 +00:00
Antony Lee
22c8736e2b Add XFAIL test for issue #160, "subshells highlighted incorrectly". 2015-10-23 03:31:00 +00:00
Daniel Shahaf
c30301d474 Drop unnecessary shebang lines.
All these files should be sourced, not executed; and Debian's lintian complains:

W: zsh-syntax-highlighting: script-not-executable usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
2015-10-20 11:49:51 +00:00
Daniel Shahaf
5cd1fb26c0 Resolve tilde expansions in command word.
This causes '~/bin/foo' to highlight as a command, rather than as a file.

Part of issue #201.
2015-09-30 00:49:34 +00:00
Daniel Shahaf
69203b1a1d Don't highlight escaped globbing.
Fixes zsh-users/zsh-syntax-highlighting#193.
2015-09-29 23:44:57 +00:00
Daniel Shahaf
800158745a Highlight quoted command words correctly.
Fixes zsh-users/zsh-syntax-highlighting#147.
2015-09-28 19:49:39 +00:00
Daniel Shahaf
7b4598a764 Highlight arithmetic expansions.
Fixes zsh-users/zsh-syntax-highlighting#188 in the case that both the
opening '((' and closing '))' have been typed,  The case that only the
opening '((' have been typed is also fixed, but requires a zsh development
build (zsh-5.1.1-52-g4bed2cf or newer); see comments within.
2015-09-28 13:55:38 +00:00
Daniel Shahaf
52a2ef644b Don't highlight escaped globbing.
Fixes zsh-users/zsh-syntax-highlighting#193.
2015-09-27 16:28:32 +00:00
Daniel Shahaf
6488284814 back-dollar-quoted-argument: Highlight incomplete escape sequences as unknown-token
Followup to 219184f046, which fixed issue #196.
2015-09-27 15:59:04 +00:00
Daniel Shahaf
f657406159 minor: Fix comment in last ocmmit. 2015-09-26 18:59:16 +00:00
Daniel Shahaf
8b728522de Add test for empty commands.
Related to issue #205.
2015-09-26 18:28:56 +00:00
Daniel Shahaf
4ec821b2b1 Highlight redirections.
Fixes zsh-users/zsh-syntax-highlighting#23.

* danielsh/i23-highlight-redirections:
  Highlight redirections.
2015-09-26 17:58:07 +00:00
Daniel Shahaf
6732783d46 back-dollar-quoted-argument: Correct an off-by-one.
Highlight the last character of a «\xHH» escape when it is the last thing in
LBUFFER.  This is similar to what b0cc02ed86 did
for issue #186.
2015-09-26 01:09:37 +00:00
Daniel Shahaf
8a43bd2cd9 back-dollar-quoted-argument: Highlight \uHHHH and \UHHHHHHHH escapes. 2015-09-25 21:45:38 +00:00
Daniel Shahaf
69fcb40275 Highlight backslash escapes within $'' strings.
Correct highlighting of backslash escapes within "" strings: highlight only
the four specific escape sequences defined there.

Fixes zsh-users/zsh-syntax-highlighting#196.
2015-09-25 21:45:38 +00:00
Daniel Shahaf
040df93c01 Highlight redirections.
Fixes zsh-users/zsh-syntax-highlighting#23.
2015-09-25 12:42:34 +00:00
Daniel Shahaf
66eb801358 dollar-double-quoted-argument: Handle «"foo$"» correctly. 2015-09-24 19:03:17 +00:00
Daniel Shahaf
b0cc02ed86 dollar-double-quoted-argument: Highlight "$foo" better.
Now, «"$42foo"» doesn't highlight the «foo», and «"$bar» highlights the «r».
2015-09-24 19:03:00 +00:00
Daniel Shahaf
9e80fe8f02 Bump copyright years. 2015-09-24 16:46:28 +00:00
Daniel Shahaf
001e6cb404 tests: Cover 'back-quoted-argument'.
This is part of issue zsh-users/zsh-syntax-highlighting#198.
2015-09-23 15:41:17 +00:00
Daniel Shahaf
22fa215e05 Fixup last commit.
* highlighters/main/test-data/hashed-command.zsh:
    Set the right region key.  This makes the test more specific.
    (Issue #184 would have caught this bug.)
2015-09-23 15:39:53 +00:00
Daniel Shahaf
845361ef3d tests: Cover 'hashed-command'.
This is part of issue zsh-users/zsh-syntax-highlighting#198.
2015-09-23 15:35:56 +00:00
Daniel Shahaf
4594d8b7ec Merge remote-tracking branch 'danielsh/i199-semicolon-v1'
* danielsh/i199-semicolon-v1:
  Fix regression: Highlight ';' as commandseparator.
  Follow-up to 547b8be304: Fix $observed_result calculation.

Fixes zsh-syntax-highlghting/zsh-users#199.
2015-09-23 15:23:25 +00:00
Daniel Shahaf
5fb4cb2f72 Fix regression: Highlight ';' as commandseparator.
This was broken by c2b9327b07
and tracked as zsh-users/zsh-syntax-highlighting#199.

This fixes the vanilla-newline.zsh test, which was was (consciously) broken
by the previous commit.
2015-09-23 14:50:22 +00:00
Daniel Shahaf
f7cb4741d6 Followup to previous: Extend the 'alias' test. 2015-09-18 22:04:07 +00:00
Daniel Shahaf
81c8d78d12 tests: Cover 'alias' and 'suffix-alias'.
This is part of issue zsh-users/zsh-syntax-highlighting#198.
2015-09-18 21:42:22 +00:00
Daniel Shahaf
8767e0ef66 tests: Cover 'reserved-word'.
This is part of issue zsh-users/zsh-syntax-highlighting#198.
2015-09-18 20:38:32 +00:00
Daniel Shahaf
b056f592f2 tests: Cover 'path_prefix'.
This is part of issue zsh-users/zsh-syntax-highlighting#198.
2015-09-18 20:21:19 +00:00
Daniel Shahaf
e0a7ddb6ec tests: Cover 'history-expansion'.
This is part of issue zsh-users/zsh-syntax-highlighting#198.
2015-09-18 20:01:10 +00:00
Daniel Shahaf
416934202e tests: Cover 'single-quoted-argument', 'double-hyphen-option', and 'function'.
This is part of issue zsh-users/zsh-syntax-highlighting#198.
2015-09-18 19:21:21 +00:00
Daniel Shahaf
627eb71940 tests: Use $unused_highlight in more places.
Notably, the 'single-hyphen-option' and 'assign' contexts both default to the
'none' style, so before this patch, the tests would not have detected a failure
to apply those two contexts.

For other contexts, using $unused_highlight only helps detect the case where
the right highlight style (e.g., 'fg=yellow') is used as a result of applying
the wrong context — which should be a theoretical failure mode.

This is part of zsh-users/zsh-syntax-highlighting#198.
2015-09-18 18:44:45 +00:00
Daniel Shahaf
404d498e1d tests: vanilla-newline.zsh: Fix expectations 2015-09-17 23:33:56 +00:00
Daniel Shahaf
0d3a5dadea tests: Add test for escape sequences in double-quoted strings 2015-09-17 20:01:46 +00:00
Daniel Shahaf
186536705b tests: path-tilde-named.zsh: Fix expectations
The path string ends at offset 26, not 23.
2015-09-17 19:09:33 +00:00
Daniel Shahaf
547b8be304 test harness: Fix off-by-one discrepancy between observed and expected.
Fixes zsh-users/zsh-syntax-highlighting#195.

The one revision made on master between this branch's creation and merge
already uses correct offsets.

* danielsh/i195-tests-offbyone-v1:
  New test for dollar-double-quoted-argument.
  test harness: Fix off-by-one discrepancy between observed and expected.
2015-09-17 19:08:29 +00:00
Daniel Shahaf
80587e5419 New test for dollar-double-quoted-argument.
This exercises the previous patch.
2015-09-12 20:48:25 +00:00
Daniel Shahaf
c46b8d169e test harness: Fix off-by-one discrepancy between observed and expected.
Fixes issue #195.
2015-09-12 20:48:25 +00:00
Daniel Shahaf
a8afbdf2f5 Support $''-quoted strings.
This does not yet highlight backslash escapes within them.
2015-09-10 20:02:39 +00:00
Daniel Shahaf
e13c5a1611 Highlight 'noglob' correctly in more cases.
Fixes zsh-users/zsh-syntax-highlighting#189.
2015-09-07 18:07:59 +00:00
Daniel Shahaf
dc701501e5 Highlight ? as globbing.
Fixes zsh-users/zsh-syntax-highlighting#94.
2015-09-07 18:03:14 +00:00
Daniel Shahaf
b3ceea8511 Highlight 'noglob' correctly in more cases.
Fixes zsh-users/zsh-syntax-highlighting#189.
2015-09-07 09:09:17 +00:00
Daniel Shahaf
546a5288e2 multiline strings: Add a second test for commit ff4d402e9a 2015-09-05 15:08:08 +00:00
Daniel Shahaf
7f41967a17 Highlight array appends: foo+=(bar baz).
Fixes zsh-users/zsh-syntax-highlighting#181.
2015-09-05 09:38:02 +00:00
Daniel Shahaf
51aed8a765 Merge remote-tracking branch 'upstream/pr/179'
* upstream/pr/179:
  Don't parse first word of array assignment as command
2015-09-04 17:57:08 +00:00
Daniel Shahaf
42495cc5d6 Merge remote-tracking branch 'upstream/pr/161'
* upstream/pr/161:
  Don't highlight prefix redirections as error
2015-09-04 17:27:25 +00:00
Daniel Shahaf
c2b9327b07 Support literal newlines, part 2 2015-09-02 09:30:08 +00:00
Daniel Shahaf
b9b67b9f78 Don't parse first word of array assignment as command
Fixes zsh-users/zsh-syntax-highlighting#178
2015-08-28 09:52:52 +00:00
Daniel Shahaf
359d48bf78 Don't highlight prefix redirections as error
Fixes zsh-users/zsh-syntax-highlighting#146
2015-02-16 02:44:56 +00:00
Daniel Shahaf
384be15b13 Support literal newlines 2015-01-27 10:23:59 +00:00
Daniel Shahaf
23cacb12fe Support backslash continuations 2015-01-27 10:23:59 +00:00
Daniel Shahaf
667495bfb7 Support multiline strings 2015-01-27 10:23:58 +00:00
Antoine Catton
3b3a58be91 Fix #121: sudo syntax highlighting incorrectly
Parse sudo command line in order to highlight the options correctly
2013-09-28 19:33:34 -06:00
Takeshi Banse
1d729202ec add tests for handling tildes
Signed-off-by: Takeshi Banse <takebi@laafc.net>
2011-09-07 01:14:45 +08:00
Takeshi Banse
48a18291f9 add some tests
Signed-off-by: Takeshi Banse <takebi@laafc.net>
2011-09-07 01:14:45 +08:00
Andreas Gahr
33813c6a52 simple testcases for bracket highlighter 2011-08-05 16:25:47 +02:00
Julien Nicoulaud
0772ddd346 Big refactoring.
* Don't override user defined styles
* Better modularisation of highlighters
* Allow to define which highlighters are activated
* Allow to define the order in which they are defined
* Minor performance optimizations
* Fixed some variables leak
* Improve documentation
* Brackets highlighter: use ZSH_HIGHLIGHT_STYLES instead of a specific array
2011-06-12 22:57:14 +02:00