Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use zle-line-pre-redraw (the feature/redrawhook branch) #749

Merged
merged 29 commits into from
Aug 9, 2020

Conversation

danielshahaf
Copy link
Member

@danielshahaf danielshahaf commented Jul 14, 2020

This is the PR of #245. Creating it for convenience and to trigger CI before merging this to master.

Review with whitespace changes ignored.

danielshahaf and others added 26 commits October 11, 2018 22:04
This feature will be released in zsh 5.3.  Older zsh's will use the existing
codepath.
…s present.

Based on code by Bart Schaefer (reference within).

Tested with zsh 5.0.7-5 (debian package) and with 5b4cbcc842c6 (39158,
5.3-to-be of today).
Currently, without zsh/zle loaded, the tests silently fall back to the
5.2-and-earlier codepath; see:
.
    #356 (comment)
This avoids a bug in zsh 4.3.12 and prior which affects passing
arguments to an anonymous function.
…-redraw hooks from running.

Without this patch, `_zsh_highlight` was invoked by add-zle-hook-widget
with `$?` being non-zero (see add-zle-hook-widget:48-52).  Since
`_zsh_highlight` preserves `$?` from its caller's point of view,
add-zle-hook-widget saw a non-zero exit code from `_zsh_highlight` and
did not run any the remaining zle-line-pre-redraw hooks.

See #579 (comment).
* 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.
  ...
* origin/master:
  driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function.
* origin/master:
  Revert "driver: Move the initialization of $zsh_highlight__memo_feature out of the entry point function."
@danielshahaf danielshahaf added this to the 0.8.0 milestone Jul 14, 2020
@danielshahaf danielshahaf mentioned this pull request Jul 14, 2020
11 tasks
@danielshahaf
Copy link
Member Author

danielshahaf commented Jul 14, 2020

* [ ]  Mention in changelog and/or log message _all_ issues which this fixes; see list on #245, as well as issues labelled [feature:redrawhook](https://github.com/zsh-users/zsh-syntax-highlighting/labels/feature%3Aredrawhook) and/or [widget-wrapping](https://github.com/zsh-users/zsh-syntax-highlighting/labels/widget-wrapping).

Okay, triage is done. Here's the list for the log message:


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.

#154 was fixed in xsel(1) in 2017. This patch probably fixes 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.

Fixes #735.

Unblocks administrative issue #655 (already milestoned).


That's 17 16 issues closed. Now to write changelog.md entries for all these… Would someone like to help with that, please? That'll free me to roll a beta (see #722 (comment)).

@danielshahaf
Copy link
Member Author

Just pushed a 0.8.0-alpha1-pre-redrawhook tag, so we have something to point people to if this causes regressions. (among other reasons)

* origin/master:
  Post-release version number bump.
  Tag version 0.8.0-alpha1-pre-redrawhook.
  brackets: Optimize the character iteration
…ixed by this branch.

This covers issues referenced from #245 or labelled "feature:redrawhook" or "widget-wrapping".  See #749 for details.
@danielshahaf
Copy link
Member Author

Added to changelog. I can't think of anything else to do before merging, other than remember to copy-paste all the above information into the log message.

@danielshahaf
Copy link
Member Author

Added to changelog. I can't think of anything else to do before merging, other than remember to copy-paste all the above information into the log message.

I suppose I'd better at least re-read the branch's log messages and diffs.

@danielshahaf
Copy link
Member Author

danielshahaf commented Aug 9, 2020

I suppose I'd better at least re-read the branch's log messages and diffs.

Issues:

  • Some intermediate states do not interoperate with other plugins (e.g., aed99f6 (the first commit), and the bugs fixed by commits b08d508 and 59cb9a5).
  • Commit d4ab7e5 could have benefited from a better log message (but changing that now would break things for everyone who uses this branch in production, so let's not do that).
  • Uses the memo= feature from zsh 5.9-to-be (commits 59cb9a5 and cb33cc0); see 810c2dc.

…ure.

The new codepath is used in 5.8.0.2 and newer; see zsh-syntax-highlighting.zsh:417.
@danielshahaf danielshahaf merged commit 239c720 into master Aug 9, 2020
danielshahaf added a commit that referenced this pull request Aug 9, 2020
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
#749 (comment),
but repeated here for the sake of github's commit-to-issue linking magic.)
@danielshahaf
Copy link
Member Author

* [ ]  Add them to the log message

Forgot this, so did it in a dedicated commit, c14fcad, instead.

jirutka added a commit to jirutka/zsh-history-substring-search that referenced this pull request Aug 7, 2022
zsh-syntax-highlighting started using zle-line-pre-redraw hook instead
of the legacy "bind all widgets" if 1) zsh has the memo= feature (added
in version 5.9) and 2) add-zle-hook-widget is available.

Now when zsh-history-substring-search is loaded before
zsh-syntax-highlighting, it causes error:

    _zsh_highlight_widget_zle-line-pre-redraw: job table full or recursion limit exceeded

See zsh-users/zsh-syntax-highlighting#749
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants