zsh-autosuggestions/CHANGELOG.md
Daniel Portales a98dd4abcf Fix region_highlight entries leaking across accept/edit cycles
Before this change, the highlight module tracked only the most recent
plugin-owned entry in a scalar (_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT) and
relied on a parameter-expansion subtraction to remove it:

    region_highlight=("${(@)region_highlight:#$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT}")

That has two failure modes:

1. The tracked string is expanded as a zsh glob pattern. If the user's
   ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE contains characters like `#`
   (e.g. `fg=#RRGGBB`), the entry is never removed and orphans
   accumulate in region_highlight across redraws. See #789.

2. Only one entry can be tracked at a time. When apply is called
   repeatedly without a successful reset (which happens under fast edits
   and widget-wrapping interactions), every apply overwrites the tracked
   reference and previous entries are orphaned.

Both manifest as stale suggestion colors bleeding onto accepted text,
typically in combination with zsh-syntax-highlighting (whose entries
interleave with ours in region_highlight).

Changes:

* Track every plugin-owned entry in an array
  (_ZSH_AUTOSUGGEST_OWNED_HIGHLIGHTS).

* On zsh 5.9+, tag each entry with `memo=zsh-autosuggestions` and on
  reset strip by memo in a single pass — robust regardless of how other
  plugins manipulate region_highlight. This matches the mechanism
  zsh-syntax-highlighting has used since 0.8.0.

* On zsh < 5.9, remove owned entries by literal string comparison
  (loop, not pattern expansion) to avoid the `#`-as-glob issue.

* _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT is retained and kept in sync for
  backwards compatibility with any external consumer.

Adds spec/highlight_spec.rb covering:
  - round-trip with a hex-colored style (regression for #789)
  - reset does not touch foreign region_highlight entries
  - accumulated orphans from repeated apply calls are all cleaned up

Supersedes #790 (which used `shift -p region_highlight` — incorrect
when another plugin has appended the most-recent entry).

Fixes #789, #698.
2026-04-20 07:52:36 -06:00

5.2 KiB

Changelog

Unreleased

  • Fix region_highlight entries leaking across accept/edit cycles, causing stale colors to bleed onto accepted text (#698, #789). Plugin-owned entries now carry a memo=zsh-autosuggestions tag on zsh 5.9+ and are tracked individually for older versions.

v0.7.1

  • Clear POSTDISPLAY instead of unsetting (#634)
  • Always reset async file descriptor after consuming it (#630)
  • Always use builtin exec (#628)
  • Add history-beginning-search-*-end widgets to clear widget list (#619)
  • Switch CI from Circle CI to GitHub Actions

v0.7.0

  • Enable asynchronous mode by default (#498)
  • No longer wrap user widgets starting with autosuggest- prefix (#496)
  • Fix a bug wrapping widgets that modify the buffer (#541)

v0.6.4

  • Fix vi-forward-char triggering a bell when using it to accept a suggestion (#488)
  • New configuration option to skip completion suggestions when buffer matches a pattern (#487)
  • New configuration option to ignore history entries matching a pattern (#456)

v0.6.3

  • Fixed bug moving cursor to end of buffer after accepting suggestion (#453)

v0.6.2

  • Fixed bug deleting the last character in the buffer in vi mode (#450)
  • Degrade gracefully when user doesn't have zsh/system module installed (#447)

v0.6.1

  • Fixed bug occurring when _complete had been aliased (#443)

v0.6.0

  • Added completion suggestion strategy powered by completion system (#111)
  • Allow setting ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE to an empty string (#422)
  • Don't fetch suggestions after copy-earlier-word (#439)
  • Allow users to unignore zle-* widgets (e.g. zle-line-init) (#432)

v0.5.2

  • Allow disabling automatic widget re-binding for better performance (#418)
  • Fix async suggestions when SH_WORD_SPLIT is set
  • Refactor async mode to use process substitution instead of zpty (#417)

v0.5.1

  • Speed up widget rebinding (#413)
  • Clean up global variable creations (#403)
  • Respect user's set options when running original widget (#402)

v0.5.0

  • Don't overwrite config with default values (#335)
  • Support fallback strategies by supplying array to suggestion config var
  • Rename "default" suggestion strategy to "history" to name it based on what it actually does
  • Reset opts in some functions affected by GLOB_SUBST (#334)
  • Support widgets starting with dashes (ex: -a-widget) (#337)
  • Skip async tests in zsh versions less than 5.0.8 because of reliability issues
  • Fix handling of newline + carriage return in async pty (#333)

v0.4.3

  • Avoid bell when accepting suggestions with autosuggest-accept (#228)
  • Don't fetch suggestions after [up,down]-line-or-beginning-search (#227, #241)
  • We are now running CI against new 5.5.1 version
  • Fix partial-accept in vi mode (#188)
  • Fix suggestion disappearing on fast movement after switching to vicmd mode (#290)
  • Fix issue rotating through kill ring with yank-pop (#301)
  • Fix issue creating new pty for async mode when previous pty is not properly cleaned up (#249)

v0.4.2

  • Fix bug in zsh versions older than 5.0.8 (#296)
  • Officially support back to zsh v4.3.11

v0.4.1

  • Switch to [[ and (( conditionals instead of [ (#257)
  • Avoid warnnestedvar warnings with typeset -g (#275)
  • Replace tabs with spaces in yaml (#268)
  • Clean up and fix escaping of special characters (#267)
  • Add emacs-forward-word to default list of partial accept widgets (#246)

v0.4.0

  • High-level integration tests using RSpec and tmux
  • Add continuous integration with Circle CI
  • Experimental support for asynchronous suggestions (#170)
  • Fix problems with multi-line suggestions (#225)
  • Optimize case where manually typing in suggestion
  • Avoid wrapping any zle-* widgets (#206)
  • Remove support for deprecated options from v0.0.x
  • Handle history entries that begin with dashes
  • Gracefully handle being sourced multiple times (#126)
  • Add enable/disable/toggle widgets to disable/enable suggestions (#219)

v0.3.3

  • Switch from $history array to fc builtin for better performance with large HISTFILEs (#164)
  • Fix tilde handling when extended_glob is set (#168)
  • Add config option for maximum buffer length to fetch suggestions for (#178)
  • Add config option for list of widgets to ignore (#184)
  • Don't fetch a new suggestion unless a modification widget actually modifies the buffer (#183)

v0.3.2

  • Test runner now supports running specific tests and choosing zsh binary
  • Return code from original widget is now correctly passed through (#135)
  • Add vi-add-eol to list of accept widgets (#143)
  • Escapes widget names within evals to fix problems with irregular widget names (#152)
  • Plugin now clears suggestion while within a completion menu (#149)
  • .plugin file no longer relies on symbolic link support, fixing issues on Windows (#156)

v0.3.1

  • Fixes issue with vi-next-char not accepting suggestion (#137).
  • Fixes global variable warning when WARN_CREATE_GLOBAL option enabled (#133).
  • Split out a separate test file for each widget.

v0.3.0

  • Adds autosuggest-execute widget (PR #124).
  • Adds concept of suggestion "strategies" for different ways of fetching suggestions.
  • Adds "match_prev_cmd" strategy (PR #131).
  • Uses git submodules for testing dependencies.
  • Lots of test cleanup.
  • Various bug fixes for zsh 5.0.x and sh_word_split option.

v0.2.17

Start of changelog.