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.
The testing docker image has been split up. Instead of having one image
with all supported versions of zsh installed, we now have a separate
image for each supported zsh version.
We use GitHub Action matrices to run jobs in parallel for all of the
supported versions.
We no longer need to publish images to Docker Hub. The images are just
built by CI (or developers) as needed from the Dockerfile in the repo.
There's something funny occasionally happening when `with_history` is
used twice in the same test. It seems to be happening more frequently
since asynchronous mode was enabled by default. My guess is it has
something to do with the `C-c` keys being sent toward the end not
consistently terminating the prompt. But I'm really not sure how it
would ever get into a `then` block like it seems to:
```
Failure/Error: wait_for { session.content }.to eq('echo "hello\nworld"')
expected: "echo \"hello\\nworld\""
got: "then> echo \"hello\\"
```
Sticking to only one `with_history` per terminal session (per test)
seems to fix the flakiness.
I also removed an old test case because I could not understand why it
was necessary and so couldn't write a good description for it. Could be
we'll need to add it back in at some point.