Commit graph

1306 commits

Author SHA1 Message Date
Daniel Shahaf
0ddb1a8d51 driver: Bump the in-development is-at-least checks so they return false on zsh 5.8.1, released yesterday.
Fixes #856
Fixes #857
2022-02-13 18:03:11 +00:00
Daniel Shahaf
c10808ad5f main: New test for issue #854 2022-01-31 09:54:57 +00:00
Daniel Shahaf
b392045e6f driver: Simplify grammar of a comment. No functional change. 2022-01-31 09:54:57 +00:00
Daniel Kuettel
c7caf57ca8 check KEYS_QUEUED_COUNT and PENDING to skip parsing when pasting 2021-11-14 02:45:00 +00:00
Leonardo Gama
1a9264bc66 docs: Add regexp to the list of built-in highlighters 2021-09-24 00:40:57 -03:00
Leonardo Gama
f6a22fa842 docs: Change highlighters' URL indexes from numbers to labels 2021-09-24 00:40:39 -03:00
a1346054
6e0e950154 *: Fix spelling
Part of PR #832.
2021-08-20 11:30:10 +00:00
Matthew Martin
dffe304567 CI: Pull image from the GitHub container registry 2021-07-03 14:33:17 -05:00
Matthew Martin
f0e6a8ef5c main: Honor shwordsplit when expanding parameters
Closes #687, #818.
2021-06-28 23:02:31 -05:00
Matthew Martin
0e1bb14452 main: precommands += proxychains 2021-05-29 23:24:58 -05:00
Matthew Martin
894127b221 docs,CI: Switch to Libera.Chat 2021-05-20 20:10:34 -05:00
Daniel Shahaf
ebef4e5569 docs: Use SSL for the link to zsh's homepage. 2021-04-14 10:39:18 +00:00
Robert
993a07fc7f docs: Fix broken link to fish shell 2021-04-14 10:39:18 +00:00
Nikola Knezevic
e8517244f7 main: Allow for "]" in shell aliases
PR #776 fixed an issue with complex aliases and expansion. However, this change
also introduced a problem with aliases which contain `]` (for example, commonly
seen on macOS: `alias ]=open`), due to using an associative array `seen_alias`,
indexed by the alias name. Due to `"$seen_alias[$arg]"`, it would fail when
`$arg` is expanded to anything containing `]`'. Thus, typing `] /` would result
in:

```
> ] /
(anon):unset:3: seen_alias[]]: invalid parameter name
```

This change fixes the issue by ensuring we properly access keys in the
associative array `seen_alias`.

Older versions of zsh have issues with map keys having special
characters, especially lacking ways to remove such keys. The
issue is described in detail in
https://unix.stackexchange.com/questions/626393/in-zsh-how-do-i-unset-an-arbitrary-associative-array-element.

This fix uses proposal from
[zsh-workers/43269](https://www.zsh.org/mla/workers/2018/msg01073.html),
discovered by Stephane Chazelas, that boils down to avoid removing keys
from the map, and reconstruct the map anew with some keys omitted.

Co-authored-by: @phy1729
2021-03-04 20:29:43 -06:00
Daniel Shahaf
205bc7ea19 'main': Disable a lint warning when env(1) was followed by a pipe.
Fixes #797.
2021-03-01 20:21:39 +00:00
Matthew Martin
5eb494852e Switch to GitHub Actions from Travis 2020-12-25 16:43:50 -06:00
Matthew Martin
75c0eb0717 main: Remember nest level an alias was seen in for seen_alias
Fixes #775.
2020-12-25 16:39:07 -06:00
Matthew Martin
046cb03a12 main: Convert in_alias to an array of shift counts
No functional change. Keeps track of how deep we are in expanding nested
aliases for the next commit.
2020-12-25 16:39:07 -06:00
Hussaina Begum Nandyala
1715f39a46 docs: Add resource link for NetBSD operating system
Signed-off-by: Hussaina Begum Nandyala <hexxdump@gmail.com>
2020-11-02 12:18:01 -06:00
Matthew Martin
2ebfa6a598 main: Forget seen aliases when starting a new command
Fixes #769
2020-10-12 19:29:53 -05:00
Matthew Martin
aac09942b8 Revert "tests: Add a test that 'rehash' isn't run."
This reverts commit 62c5575848.

The test fails when zsh/parameter is available.
2020-10-12 19:28:53 -05:00
Roman Perepelitsa
62c5575848 tests: Add a test that 'rehash' isn't run.
See comments within for the rationale.

This is a regression test for a regression that was only present in development
versions of PR #764 and was never present in master.
2020-08-26 08:47:06 +00:00
Ivo Šmerek
4cf464f843 docs: Update Gentoo link 2020-08-16 13:12:46 +00:00
Daniel Shahaf
6d5372a937 tests: parameter-to-global-alias: Fix a false positive failure when 'x' happens to be a valid external command name.
Reported on issue #757 along with other issues.
2020-08-11 09:21:21 +00:00
Daniel Shahaf
e9cad1493f changelog: Document #712 under the last tag, 0.8.0-alpha1-pre-redrawhook. 2020-08-11 08:42:59 +00:00
m0viefreak
79b6e7e05f tests: precommand-killing1: Use a dummy path that always exists
E.g., on Cygwin /etc/passwd does not necessarily exist.
2020-08-11 08:13:17 +00:00
Daniel Shahaf
3944a44ffe driver: Fix a version number check to work around a bug in the zsh version whereunder the check should return false.
The bug is as follows:

    % zsh-5.8 -fc 'autoload is-at-least; is-at-least 5.8.0.2 && echo yes || echo no'
    yes
    % zsh-5.8 -fc 'autoload is-at-least; is-at-least 5.8.0.2 $ZSH_VERSION && echo yes || echo no'
    yes

This commit deploys the following workaround:

    % zsh-5.8 -fc 'autoload is-at-least; is-at-least 5.8.0.2 $ZSH_VERSION.0.0 && echo yes || echo no'
    no

Fixes #756.
2020-08-10 07:40:01 +00:00
Matthew Martin
34674d7860 docs: Add OpenBSD port 2020-08-09 13:08:29 -05:00
Matthew Martin
e4d1db1e2c docs: Sort INSTALL.md 2020-08-09 13:08:29 -05:00
Daniel Shahaf
c14fcad3b0 empty commit: Close redrawhook bugs
The parent commit, which merged the feature/redrawhook bug and thereby
closed PR #749, also fixed the following issue:

Fixes #40.

Fixes #90, closes #470. (The latter is a PR for the former.)

Fixes #150, closes #151, closes #160. (The latter two are PR's for the first one.) The related issue #183 appears to have been fixed in master. For #150, a different fix for older versions of zsh was considered but has not been implemented.

Issue #154 was fixed in xsel(1) in 2017. The parent commit probably fixed that issue for pre-2017 xsel(1).

Is #245, #356, and #749. Fixes #245 (redrawhook umbrella issue).

Does not reintroduce #257 (comment).

Does not reintroduce #259 (comment)

Closes #281 as obsolete.

Fixes #295.

Fixes #324.

Fixes #375.

Fixes #377.

Closes #421 as obsolete.

Fixes #520.

Unblocks #536 (already milestoned).

Fixes #632.

Unblocks #635. Milestoned.

Unblocks #688. Milestoned.

Unblocks administrative issue #655 (already milestoned).

(The above is copied from
https://github.com/zsh-users/zsh-syntax-highlighting/pull/749#issuecomment-658407330,
but repeated here for the sake of github's commit-to-issue linking magic.)
2020-08-09 11:09:19 +00:00
Daniel Shahaf
239c720dec Merge branch 'feature/redrawhook'
* feature/redrawhook:
  docs: Track making the new codepath conditional upon the 'memo=' feature.
  On the feature/redrawhook branch, changelog: Add entries for issues fixed by this branch.
  On the feature/redrawhook branch, change the detection of the 'memo=' feature to avoid a catch-22.
  driver: Make the redrawhook codepath conditional upon the memo= feature.
  On the feature/redrawhook branch, move the changelog entry to the current release's section.
  driver: Fix a bug that prevented subsequent, third-party zle-line-pre-redraw hooks from running.
  driver: Do not pass widget arguments to _zsh_highlight
  driver: Clarify comment.  No functional change.
  driver: Allow for -U in autoloaded function definition
  driver: Use idiomatic module check
  driver: Make the shadowing $WIDGET read only.
  driver: Avoid a fork in the common case.
  test harness: Actually test the new code.
  driver: Rewrite without a state variable
  noop: Make a whitespace-only change to reduce noise in the next commit.
  docs: Rewrap.
  docs: Update FAQ answer per changes on this branch.
  redo _zsh_highlight__function_callable_p
  driver: Use a different way of checking whether add-zle-hook-widget is present.
  changelog: Use a more specific link.
  changelog: Note the effect of fixing #245/#90 and an alternative.
  driver: Pass zle-line-finish arguments on to _zsh_highlight.
  driver: Hook zle-line-finish.
  driver: Reimplement using 'add-zle-hook-widget zle-line-pre-redraw'
  wrappers: Reimplement using Mikachu's zle-line-pre-redraw hook (workers/36650).
2020-08-09 11:00:45 +00:00
Daniel Shahaf
7cc6226477 docs: Track making the new codepath conditional upon the 'memo=' feature.
The new codepath is used in 5.8.0.2 and newer; see zsh-syntax-highlighting.zsh:417.
2020-08-09 10:56:18 +00:00
Daniel Shahaf
cba4a1bc2e On the feature/redrawhook branch, changelog: Add entries for issues fixed by this branch.
This covers issues referenced from #245 or labelled "feature:redrawhook" or "widget-wrapping".  See #749 for details.
2020-07-14 23:20:29 +00:00
Daniel Shahaf
637e1c702e Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master:
  Post-release version number bump.
  Tag version 0.8.0-alpha1-pre-redrawhook.
  brackets: Optimize the character iteration
2020-07-14 22:49:17 +00:00
Daniel Shahaf
2d60a47cc4 Post-release version number bump. 2020-07-14 21:33:52 +00:00
Daniel Shahaf
00a5fd11eb Tag version 0.8.0-alpha1-pre-redrawhook. 2020-07-14 21:31:39 +00:00
Daniel Shahaf
cdd7f899cb brackets: Optimize the character iteration
Test case: See the first comment of issue #295.

Before:
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)   14         284.67    20.33   82.84%    284.67    20.33   82.84%  _zsh_highlight_highlighter_brackets_paint
 2)   15         313.72    20.91   91.30%     26.62     1.77    7.75%  _zsh_highlight
 3)   14         318.68    22.76   92.74%      7.41     0.53    2.16%  _zsh_highlight_call_widget

After:
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)   15          57.25     3.82   45.33%     28.30     1.89   22.41%  _zsh_highlight
 2)   14          81.96     5.85   64.90%     27.02     1.93   21.40%  _zsh_highlight_call_widget
 3)   14          26.31     1.88   20.84%     26.31     1.88   20.84%  _zsh_highlight_highlighter_brackets_paint
 4)    2          10.66     5.33    8.44%      8.97     4.49    7.10%  VCS_INFO_formats
 5)    2          25.92    12.96   20.52%      7.72     3.86    6.11%  VCS_INFO_get_data_git

(That's not in my everyday configuration but in my minimal testing
setup, which runs vcs_info with the default settings.)
2020-07-14 20:19:40 +00:00
Daniel Shahaf
cb33cc0081 On the feature/redrawhook branch, change the detection of the 'memo=' feature to avoid a catch-22. 2020-07-14 02:37:41 +00:00
Daniel Shahaf
9ce3540d74 Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master:
  Revert "driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function."
2020-07-14 02:31:24 +00:00
Daniel Shahaf
d62baa50f4 Revert "driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function."
This reverts commit 8a1bd7c8b6.

The detection only works correctly from a widget function, so the change
was wrong: it caused zsh_highlight__memo_feature to be set to false
every time.
2020-07-14 02:29:46 +00:00
Daniel Shahaf
59cb9a560d driver: Make the redrawhook codepath conditional upon the memo= feature.
Fixes #579 (zsh-autosuggestions interoperability).
Fixes #735 (ditto).

See https://github.com/zsh-users/zsh-syntax-highlighting/issues/579#issuecomment-650126055
See https://github.com/zsh-users/zsh-autosuggestions/issues/529#issuecomment-650481227
2020-07-14 02:13:51 +00:00
Daniel Shahaf
7b863fb413 Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master:
  driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function.
2020-07-14 02:08:20 +00:00
Daniel Shahaf
8a1bd7c8b6 driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function.
This is needed for feature/redrawhook to be able to use it.
2020-07-14 02:07:32 +00:00
Daniel Shahaf
daf0d94bae On the feature/redrawhook branch, move the changelog entry to the current release's section. 2020-07-14 02:00:45 +00:00
Daniel Shahaf
c28312b9d3 Merge remote-tracking branch 'origin/master' into feature/redrawhook
* origin/master: (297 commits)
  driver: Follow-up to grandparent: Have all test suite entry points declare the mock $region_highlight.
  Use the new, unreleased zsh 'memo=' feature to remove only our own entries from $region_highlight.
  driver: Stop re-declaring $region_highlight.  It's unneeded.
  docs: regexp highlighter: Fix a wrong associative array name in the example.
  docs: Fix obs-repository link
  tests: Fix a wrong value of $PREBUFFER in a test, and add checks to prevent this from recurring.
  test harness: Fix use of an undefined variable in an error message.
  'main': Don't progress the $in_redirection staller while $in_param.
  tests: Add an XFail test for issue #712.
  'main': Highlight the parentheses of array assignments as reserved words.
  CI += zsh-5.8
  main: Add tests for arithmetic expansion
  main: Add arithmetic substitution highlighting
  changelog.md: Restore vertical whitespace before section headers.
  'main': Fix issue #677, concerning multiline aliases.
  changelog: Update through HEAD.
  'main': Further optimize argument parsing.
  'main': Optimize a hot path.
  tests: Add a performance testing script, for measuring the performance of the 'main' highlighter on a large file.
  changelog: Update through HEAD.
  test harness: Print the expected-v.-actual on every failure, not just upon cardinality failures.
  Document ZSH_HIGHLIGHT_MAXLENGTH.
  'main': Fix the last commit's bug concerning parameter elision not happening in redirects in command position.
  'main': Add a test for parameter elision not happening in redirects in command position.
  'main': Fix regression in zsh 5.3.1 and older: all precmd hooks later than z-sy-h would be aborted.
  changelog += WARN_NESTED_VAR fixes (#727, #731)
  'main': Fix a regression caused by the great-grandparent commit's WARN_NESTED_VAR fix.
  'main': Don't run `_zsh_highlight_main__type` on every non-command word.
  'make perf': Show only a cumulative datum per highligher, rather than per test file.
  'main': Don't trip WARN_NESTED_VAR.
  'main': Follow-up to previous: Document the version number, and deduplicate some option letters.
  'main': precommands += strace
  editorconfig: Fix Makefile settings
  Fix typo
  Bump copyright years.
  driver: Fix "_zsh_highlight:3: read-only variable: ret" warnings when POSIX_BUILTINS is set.
  tests: Add a test for the infinite loop fixed by each of the last two commits.
  'main': Fix expansion of positional parameters in `_zsh_highlight_main_highlighter__try_expand_parameter`.
  'main': Fix an infinite loop.
  'main': precommands += ionice(1) (from util-linux)
  driver: Simplify initialization of $zsyh_user_options in the fallback codepath.
  driver: Make sure we don't change the return value in a called function.
  'main': Make logic more robust.  No functional change.
  'main': Break out an anonymous function into a named function.
  Fix typos in comments.
  main: Add test for issue #713
  'main': Support the 'env' precommand.
  test harness: Fix the pretty-printer's padding implementation.
  Revert "test harness: Rewrite the columnar pretty-printer without external tools." and "travis: Remove bsdmainutils since column(1) has been removed, three commits ago."
  changelog: Update through HEAD.
  'main': Correctly highlight '&&' and '||' inside '[[ … ]]' conditions.
  'main': Highlight reserved words following assignments as errors.
  tests: Add tests for issue #461.
  test harness: Output the time information to the same place the test name was printed to.
  test harness: Stringify values in a more readable manner.
  tests: Add a unit test for a path specified with mixed quoting.
  tests: Add a test for issue #498, which has already been fixed.
  tests: Test that global qualifiers and command substitutions aren't evaluated.
  'main': Don't consider path_prefix in alias expansions.
  'main': Add a test for aliases to AUTO_CD directories.
  'main': Let AUTO_CD directories be highlighted with their own style.
  'main': Add an auxiliary variable for readability.
  'main': In command position, do not highlight directories (unless AUTO_CD is set) and non-executable files.
  'main': Extend tests to capture the current behaviour.
  'main': Add an XFail test for issue #202.
  'main': Highlight errors from the EQUALS option.
  'main': Let the type determination ignore global aliases when it ignores regular ones.
  'main': Add a regression test for parameters that expand to global aliases.
  'main': Enable the zsh/parameter codepath of global aliases highlighting.
  changelog: Update through HEAD.
  travis: Remove bsdmainutils since column(1) has been removed, three commits ago.
  'main': Highlight global aliases
  tests: Record current behaviour on global aliases.
  test harness: Rewrite the columnar pretty-printer without external tools.
  test harness: Fix an issue with the pretty-printed $expected_region_highlight/$region_highlight diffing.
  'main': Support the "close file descriptor" and "coproc" redirection syntaxes
  tests: Add a test for the "close file descriptor" and "coproc" redirection syntaxes
  tests: Fix the test added in the last commit.
  tests: Add a test for issue #705, concerning continuation lines.
  test harness: Let tests fail early by exiting non-zero or by setting a flag.
  test harness: Print the test name when $skip_test is set.
  test harness: Remove a bogus check.
  test harness: Fix $skip_test support, broken yesterday.
  travis: Install bsdmainutils to provide column(1).
  test harness: When the cardinality check fails, pretty-print \$expected_region_highlight and \$region_highlight.
  test harness: Don't leak options from test files to the test harness.
  test harness: Fix test failures under zsh 5.0.8 and older.
  'main': Fix a bug manifesting under zsh 5.2 and older.
  'main': Don't highlight arithmetic expansions as command substitutions.
  tests: Add a test documenting the current state, prior to introducing #704.
  test harness: Change cardinality check semantics
  test harness: No-op change to minimize the next diff.
  'main': Document additional meanings of the 'S' $braces_stack flag.
  'main': When the redirection operator '>&' or '<&' is followed by a positive integer, do not consider that as a filename; it's always a file descriptor.
  'main': Add $last_arg for "lookbehind".
  noop: Clarify comment.
  'main': Honour the MULTIOS option when applying the 'globbing' style.
  'main': Document what $in_redirection is currently used for.
  'main': The optimized cmdsubst input syntax doesn't glob.
  changelog: Fix markup.
  ...
2020-07-14 01:57:55 +00:00
Daniel Shahaf
d9a7963970 driver: Follow-up to grandparent: Have all test suite entry points declare the mock $region_highlight.
tests/generate.zsh already does this.
2020-07-14 01:57:02 +00:00
Daniel Shahaf
810c2dcede Use the new, unreleased zsh 'memo=' feature to remove only our own entries from $region_highlight.
Fixes #418 (interoperability issue with other plugins).
2020-07-14 00:32:36 +00:00
Daniel Shahaf
075c852924 driver: Stop re-declaring $region_highlight. It's unneeded. 2020-07-14 00:32:36 +00:00
Nuri Jung
fb929edc30 docs: regexp highlighter: Fix a wrong associative array name in the example.
Factored out from #747.
2020-07-01 12:55:43 +00:00
Il Harper
91d2eeaf23 docs: Fix obs-repository link 2020-06-15 00:23:05 -05:00