Skip to content

Commit e52ee8c

Browse files
authored
Merge pull request #811 from zsh-users/develop
v0.7.1
2 parents c3d4e57 + f8907cf commit e52ee8c

12 files changed

+107
-66
lines changed

.circleci/config.yml

-15
This file was deleted.

.github/workflows/integration.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on: [push, pull_request]
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.ref }}
4+
cancel-in-progress: true
5+
env:
6+
IMAGE_CACHE_PATH: /tmp/.image-cache
7+
IMAGE_CACHE_NAME: zsh-autosuggestions-test
8+
jobs:
9+
determine-versions:
10+
runs-on: ubuntu-22.04
11+
outputs:
12+
versions: ${{ steps.set-versions.outputs.versions }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- id: set-versions
16+
run: |
17+
echo "versions=$(
18+
grep "^[^#]" ZSH_VERSIONS \
19+
| sed -E 's/(^|$)/"/g' \
20+
| paste -sd ',' - \
21+
| sed -e 's/^/[/' -e 's/$/]/'
22+
)" >> $GITHUB_OUTPUT
23+
test:
24+
needs: determine-versions
25+
runs-on: ubuntu-22.04
26+
strategy:
27+
matrix:
28+
version: ${{ fromJson(needs.determine-versions.outputs.versions) }}
29+
steps:
30+
- uses: actions/checkout@v3
31+
- name: Docker image cache
32+
id: image-cache
33+
uses: actions/cache@v3
34+
with:
35+
path: ${{ env.IMAGE_CACHE_PATH }}
36+
key: image-cache-${{ matrix.version }}-${{ hashFiles('Dockerfile', 'install_test_zsh.sh', 'Gemfile.lock') }}
37+
- name: Load cached docker image if available
38+
if: ${{ steps.image-cache.outputs.cache-hit }}
39+
run: gunzip < $IMAGE_CACHE_PATH/$IMAGE_CACHE_NAME.tar.gz | docker load
40+
- name: Build the docker image if necessary
41+
if: ${{ !steps.image-cache.outputs.cache-hit }}
42+
run: |
43+
docker build --build-arg TEST_ZSH_VERSION=${{ matrix.version }} -t $IMAGE_CACHE_NAME .
44+
mkdir -p $IMAGE_CACHE_PATH
45+
docker save $IMAGE_CACHE_NAME | gzip > $IMAGE_CACHE_PATH/$IMAGE_CACHE_NAME.tar.gz
46+
- name: Run the tests
47+
run: |
48+
docker run --rm \
49+
-v $PWD:/zsh-autosuggestions \
50+
$IMAGE_CACHE_NAME \
51+
make test

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## v0.7.1
4+
- Clear POSTDISPLAY instead of unsetting (#634)
5+
- Always reset async file descriptor after consuming it (#630)
6+
- Always use builtin `exec` (#628)
7+
- Add `history-beginning-search-*-end` widgets to clear widget list (#619)
8+
- Switch CI from Circle CI to GitHub Actions
9+
310
## v0.7.0
411
- Enable asynchronous mode by default (#498)
512
- No longer wrap user widgets starting with `autosuggest-` prefix (#496)

Dockerfile

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM ruby:2.5.3-alpine
22

3+
ARG TEST_ZSH_VERSION
4+
RUN : "${TEST_ZSH_VERSION:?}"
5+
36
RUN apk add --no-cache autoconf
47
RUN apk add --no-cache libtool
58
RUN apk add --no-cache libcap-dev
@@ -11,10 +14,8 @@ RUN apk add --no-cache tmux
1114

1215
WORKDIR /zsh-autosuggestions
1316

14-
ADD ZSH_VERSIONS /zsh-autosuggestions/ZSH_VERSIONS
15-
ADD install_test_zsh.sh /zsh-autosuggestions/install_test_zsh.sh
17+
ADD install_test_zsh.sh ./
1618
RUN ./install_test_zsh.sh
1719

18-
ADD Gemfile /zsh-autosuggestions/Gemfile
19-
ADD Gemfile.lock /zsh-autosuggestions/Gemfile.lock
20+
ADD Gemfile Gemfile.lock ./
2021
RUN bundle install

README.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ It suggests commands as you type based on history and completions.
66

77
Requirements: Zsh v4.3.11 or later
88

9-
[![CircleCI](https://img.shields.io/circleci/build/github/zsh-users/zsh-autosuggestions.svg)](https://circleci.com/gh/zsh-users/zsh-autosuggestions)
109
[![Chat on Gitter](https://img.shields.io/gitter/room/zsh-users/zsh-autosuggestions.svg)](https://gitter.im/zsh-users/zsh-autosuggestions)
1110

1211
<a href="https://asciinema.org/a/37390" target="_blank"><img src="https://asciinema.org/a/37390.png" width="400" /></a>
@@ -170,18 +169,16 @@ Tests are written in ruby using the [`rspec`](http://rspec.info/) framework. The
170169

171170
Test files live in `spec/`. To run the tests, run `make test`. To run a specific test, run `TESTS=spec/some_spec.rb make test`. You can also specify a `zsh` binary to use by setting the `TEST_ZSH_BIN` environment variable (ex: `TEST_ZSH_BIN=/bin/zsh make test`).
172171

173-
A docker image for testing is available [on docker hub](https://hub.docker.com/r/ericfreese/zsh-autosuggestions-test). It comes with ruby, the bundler dependencies, and all supported versions of zsh installed.
174-
175-
Pull the docker image with:
172+
It's possible to run the tests for any supported version of zsh in a Docker image by building an image from the provided Dockerfile. To build the docker image for a specific version of zsh (where `<version>` below is substituted with the contents of a line from the [`ZSH_VERSIONS`](ZSH_VERSIONS) file), run:
176173
177174
```sh
178-
docker pull ericfreese/zsh-autosuggestions-test
175+
docker build --build-arg TEST_ZSH_VERSION=<version> -t zsh-autosuggestions-test .
179176
```
180177
181-
To run the tests for a specific version of zsh (where `<version>` below is substituted with the contents of a line from the [`ZSH_VERSIONS`](ZSH_VERSIONS) file):
178+
After building the image, run the tests via:
182179
183180
```sh
184-
docker run -it -e TEST_ZSH_BIN=zsh-<version> -v $PWD:/zsh-autosuggestions zsh-autosuggestions-test make test
181+
docker run -it -v $PWD:/zsh-autosuggestions zsh-autosuggestions-test make test
185182
```
186183
187184

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.7.0
1+
v0.7.1

ZSH_VERSIONS

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Zsh releases to run tests against
22
# See https://github.com/zsh-users/zsh/releases
3-
#
4-
# When modifying this file, rebuild and push docker image:
5-
# $ docker build -t ericfreese/zsh-autosuggestions-test .
6-
# $ docker push ericfreese/zsh-autosuggestions-test
73
4.3.11
84
5.0.2
95
5.0.8
@@ -14,4 +10,5 @@
1410
5.5.1
1511
5.6.2
1612
5.7.1
17-
5.8
13+
5.8.1
14+
5.9

install_test_zsh.sh

+14-17
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@
22

33
set -ex
44

5-
for v in $(grep "^[^#]" ZSH_VERSIONS); do
6-
mkdir zsh-$v
7-
cd zsh-$v
5+
mkdir zsh-build
6+
cd zsh-build
87

9-
curl -L https://api.github.com/repos/zsh-users/zsh/tarball/zsh-$v | tar xz --strip=1
8+
curl -L https://api.github.com/repos/zsh-users/zsh/tarball/zsh-$TEST_ZSH_VERSION | tar xz --strip=1
109

11-
./Util/preconfig
12-
./configure --enable-pcre \
13-
--enable-cap \
14-
--enable-multibyte \
15-
--with-term-lib='ncursesw tinfo' \
16-
--with-tcsetpgrp \
17-
--program-suffix="-$v"
10+
./Util/preconfig
11+
./configure --enable-pcre \
12+
--enable-cap \
13+
--enable-multibyte \
14+
--with-term-lib='ncursesw tinfo' \
15+
--with-tcsetpgrp
1816

19-
make install.bin
20-
make install.modules
21-
make install.fns
17+
make install.bin
18+
make install.modules
19+
make install.fns
2220

23-
cd ..
21+
cd ..
2422

25-
rm -rf zsh-$v
26-
done
23+
rm -rf zsh-build

src/async.zsh

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ _zsh_autosuggest_async_request() {
1111
# If we've got a pending request, cancel it
1212
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
1313
# Close the file descriptor and remove the handler
14-
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
14+
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
1515
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
1616

1717
# We won't know the pid unless the user has zsh/system module installed
@@ -32,7 +32,7 @@ _zsh_autosuggest_async_request() {
3232
fi
3333

3434
# Fork a process to fetch a suggestion and open a pipe to read from it
35-
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
35+
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
3636
# Tell parent process our pid
3737
echo $sysparams[pid]
3838
@@ -68,9 +68,10 @@ _zsh_autosuggest_async_response() {
6868
zle autosuggest-suggest -- "$suggestion"
6969

7070
# Close the fd
71-
exec {1}<&-
71+
builtin exec {1}<&-
7272
fi
7373

7474
# Always remove the handler
7575
zle -F "$1"
76+
_ZSH_AUTOSUGGEST_ASYNC_FD=
7677
}

src/config.zsh

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
2828
history-search-backward
2929
history-beginning-search-forward
3030
history-beginning-search-backward
31+
history-beginning-search-forward-end
32+
history-beginning-search-backward-end
3133
history-substring-search-up
3234
history-substring-search-down
3335
up-line-or-beginning-search

src/widgets.zsh

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ _zsh_autosuggest_toggle() {
3030
# Clear the suggestion
3131
_zsh_autosuggest_clear() {
3232
# Remove the suggestion
33-
unset POSTDISPLAY
33+
POSTDISPLAY=
3434

3535
_zsh_autosuggest_invoke_original_widget $@
3636
}
@@ -47,7 +47,7 @@ _zsh_autosuggest_modify() {
4747
local orig_postdisplay="$POSTDISPLAY"
4848

4949
# Clear suggestion while waiting for next one
50-
unset POSTDISPLAY
50+
POSTDISPLAY=
5151

5252
# Original widget may modify the buffer
5353
_zsh_autosuggest_invoke_original_widget $@
@@ -102,7 +102,7 @@ _zsh_autosuggest_suggest() {
102102
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
103103
POSTDISPLAY="${suggestion#$BUFFER}"
104104
else
105-
unset POSTDISPLAY
105+
POSTDISPLAY=
106106
fi
107107
}
108108

@@ -128,7 +128,7 @@ _zsh_autosuggest_accept() {
128128
BUFFER="$BUFFER$POSTDISPLAY"
129129

130130
# Remove the suggestion
131-
unset POSTDISPLAY
131+
POSTDISPLAY=
132132

133133
# Run the original widget before manually moving the cursor so that the
134134
# cursor movement doesn't make the widget do something unexpected
@@ -151,7 +151,7 @@ _zsh_autosuggest_execute() {
151151
BUFFER="$BUFFER$POSTDISPLAY"
152152

153153
# Remove the suggestion
154-
unset POSTDISPLAY
154+
POSTDISPLAY=
155155

156156
# Call the original `accept-line` to handle syntax highlighting or
157157
# other potential custom behavior

zsh-autosuggestions.zsh

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Fish-like fast/unobtrusive autosuggestions for zsh.
22
# https://github.com/zsh-users/zsh-autosuggestions
3-
# v0.7.0
3+
# v0.7.1
44
# Copyright (c) 2013 Thiago de Arruda
55
# Copyright (c) 2016-2021 Eric Freese
66
#
@@ -54,6 +54,8 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
5454
history-search-backward
5555
history-beginning-search-forward
5656
history-beginning-search-backward
57+
history-beginning-search-forward-end
58+
history-beginning-search-backward-end
5759
history-substring-search-up
5860
history-substring-search-down
5961
up-line-or-beginning-search
@@ -292,7 +294,7 @@ _zsh_autosuggest_toggle() {
292294
# Clear the suggestion
293295
_zsh_autosuggest_clear() {
294296
# Remove the suggestion
295-
unset POSTDISPLAY
297+
POSTDISPLAY=
296298

297299
_zsh_autosuggest_invoke_original_widget $@
298300
}
@@ -309,7 +311,7 @@ _zsh_autosuggest_modify() {
309311
local orig_postdisplay="$POSTDISPLAY"
310312

311313
# Clear suggestion while waiting for next one
312-
unset POSTDISPLAY
314+
POSTDISPLAY=
313315

314316
# Original widget may modify the buffer
315317
_zsh_autosuggest_invoke_original_widget $@
@@ -364,7 +366,7 @@ _zsh_autosuggest_suggest() {
364366
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
365367
POSTDISPLAY="${suggestion#$BUFFER}"
366368
else
367-
unset POSTDISPLAY
369+
POSTDISPLAY=
368370
fi
369371
}
370372

@@ -390,7 +392,7 @@ _zsh_autosuggest_accept() {
390392
BUFFER="$BUFFER$POSTDISPLAY"
391393

392394
# Remove the suggestion
393-
unset POSTDISPLAY
395+
POSTDISPLAY=
394396

395397
# Run the original widget before manually moving the cursor so that the
396398
# cursor movement doesn't make the widget do something unexpected
@@ -413,7 +415,7 @@ _zsh_autosuggest_execute() {
413415
BUFFER="$BUFFER$POSTDISPLAY"
414416

415417
# Remove the suggestion
416-
unset POSTDISPLAY
418+
POSTDISPLAY=
417419

418420
# Call the original `accept-line` to handle syntax highlighting or
419421
# other potential custom behavior
@@ -766,7 +768,7 @@ _zsh_autosuggest_async_request() {
766768
# If we've got a pending request, cancel it
767769
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
768770
# Close the file descriptor and remove the handler
769-
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
771+
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
770772
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
771773

772774
# We won't know the pid unless the user has zsh/system module installed
@@ -787,7 +789,7 @@ _zsh_autosuggest_async_request() {
787789
fi
788790

789791
# Fork a process to fetch a suggestion and open a pipe to read from it
790-
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
792+
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
791793
# Tell parent process our pid
792794
echo $sysparams[pid]
793795
@@ -823,11 +825,12 @@ _zsh_autosuggest_async_response() {
823825
zle autosuggest-suggest -- "$suggestion"
824826

825827
# Close the fd
826-
exec {1}<&-
828+
builtin exec {1}<&-
827829
fi
828830

829831
# Always remove the handler
830832
zle -F "$1"
833+
_ZSH_AUTOSUGGEST_ASYNC_FD=
831834
}
832835

833836
#--------------------------------------------------------------------#

0 commit comments

Comments
 (0)