Compare commits

..

1 Commits

Author SHA1 Message Date
Eric Freese
8be05efc3c Stop requiring function_argzero
This commit is based on [zsh-syntax-highlighting's similar commit][1].

Also, motivated from PR #640.

[1]: 750aebc553
2023-09-07 09:05:38 -06:00
7 changed files with 20 additions and 27 deletions

View File

@@ -1,12 +1,5 @@
# Changelog
## 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)

View File

@@ -6,6 +6,7 @@ It suggests commands as you type based on history and completions.
Requirements: Zsh v4.3.11 or later
[![CircleCI](https://img.shields.io/circleci/build/github/zsh-users/zsh-autosuggestions.svg)](https://circleci.com/gh/zsh-users/zsh-autosuggestions)
[![Chat on Gitter](https://img.shields.io/gitter/room/zsh-users/zsh-autosuggestions.svg)](https://gitter.im/zsh-users/zsh-autosuggestions)
<a href="https://asciinema.org/a/37390" target="_blank"><img src="https://asciinema.org/a/37390.png" width="400" /></a>

View File

@@ -1 +1 @@
v0.7.1
v0.7.0

View File

@@ -11,7 +11,7 @@ _zsh_autosuggest_async_request() {
# If we've got a pending request, cancel it
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
# Close the file descriptor and remove the handler
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
# We won't know the pid unless the user has zsh/system module installed
@@ -32,7 +32,7 @@ _zsh_autosuggest_async_request() {
fi
# Fork a process to fetch a suggestion and open a pipe to read from it
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
# Tell parent process our pid
echo $sysparams[pid]
@@ -68,10 +68,9 @@ _zsh_autosuggest_async_response() {
zle autosuggest-suggest -- "$suggestion"
# Close the fd
builtin exec {1}<&-
exec {1}<&-
fi
# Always remove the handler
zle -F "$1"
_ZSH_AUTOSUGGEST_ASYNC_FD=
}

View File

@@ -30,7 +30,7 @@ _zsh_autosuggest_toggle() {
# Clear the suggestion
_zsh_autosuggest_clear() {
# Remove the suggestion
POSTDISPLAY=
unset POSTDISPLAY
_zsh_autosuggest_invoke_original_widget $@
}
@@ -47,7 +47,7 @@ _zsh_autosuggest_modify() {
local orig_postdisplay="$POSTDISPLAY"
# Clear suggestion while waiting for next one
POSTDISPLAY=
unset POSTDISPLAY
# Original widget may modify the buffer
_zsh_autosuggest_invoke_original_widget $@
@@ -102,7 +102,7 @@ _zsh_autosuggest_suggest() {
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
POSTDISPLAY="${suggestion#$BUFFER}"
else
POSTDISPLAY=
unset POSTDISPLAY
fi
}
@@ -128,7 +128,7 @@ _zsh_autosuggest_accept() {
BUFFER="$BUFFER$POSTDISPLAY"
# Remove the suggestion
POSTDISPLAY=
unset POSTDISPLAY
# Run the original widget before manually moving the cursor so that the
# cursor movement doesn't make the widget do something unexpected
@@ -151,7 +151,7 @@ _zsh_autosuggest_execute() {
BUFFER="$BUFFER$POSTDISPLAY"
# Remove the suggestion
POSTDISPLAY=
unset POSTDISPLAY
# Call the original `accept-line` to handle syntax highlighting or
# other potential custom behavior

View File

@@ -1 +1,2 @@
0=${(%):-%N}
source ${0:A:h}/zsh-autosuggestions.zsh

View File

@@ -1,6 +1,6 @@
# Fish-like fast/unobtrusive autosuggestions for zsh.
# https://github.com/zsh-users/zsh-autosuggestions
# v0.7.1
# v0.7.0
# Copyright (c) 2013 Thiago de Arruda
# Copyright (c) 2016-2021 Eric Freese
#
@@ -294,7 +294,7 @@ _zsh_autosuggest_toggle() {
# Clear the suggestion
_zsh_autosuggest_clear() {
# Remove the suggestion
POSTDISPLAY=
unset POSTDISPLAY
_zsh_autosuggest_invoke_original_widget $@
}
@@ -311,7 +311,7 @@ _zsh_autosuggest_modify() {
local orig_postdisplay="$POSTDISPLAY"
# Clear suggestion while waiting for next one
POSTDISPLAY=
unset POSTDISPLAY
# Original widget may modify the buffer
_zsh_autosuggest_invoke_original_widget $@
@@ -366,7 +366,7 @@ _zsh_autosuggest_suggest() {
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
POSTDISPLAY="${suggestion#$BUFFER}"
else
POSTDISPLAY=
unset POSTDISPLAY
fi
}
@@ -392,7 +392,7 @@ _zsh_autosuggest_accept() {
BUFFER="$BUFFER$POSTDISPLAY"
# Remove the suggestion
POSTDISPLAY=
unset POSTDISPLAY
# Run the original widget before manually moving the cursor so that the
# cursor movement doesn't make the widget do something unexpected
@@ -415,7 +415,7 @@ _zsh_autosuggest_execute() {
BUFFER="$BUFFER$POSTDISPLAY"
# Remove the suggestion
POSTDISPLAY=
unset POSTDISPLAY
# Call the original `accept-line` to handle syntax highlighting or
# other potential custom behavior
@@ -768,7 +768,7 @@ _zsh_autosuggest_async_request() {
# If we've got a pending request, cancel it
if [[ -n "$_ZSH_AUTOSUGGEST_ASYNC_FD" ]] && { true <&$_ZSH_AUTOSUGGEST_ASYNC_FD } 2>/dev/null; then
# Close the file descriptor and remove the handler
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}<&-
zle -F $_ZSH_AUTOSUGGEST_ASYNC_FD
# We won't know the pid unless the user has zsh/system module installed
@@ -789,7 +789,7 @@ _zsh_autosuggest_async_request() {
fi
# Fork a process to fetch a suggestion and open a pipe to read from it
builtin exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
exec {_ZSH_AUTOSUGGEST_ASYNC_FD}< <(
# Tell parent process our pid
echo $sysparams[pid]
@@ -825,12 +825,11 @@ _zsh_autosuggest_async_response() {
zle autosuggest-suggest -- "$suggestion"
# Close the fd
builtin exec {1}<&-
exec {1}<&-
fi
# Always remove the handler
zle -F "$1"
_ZSH_AUTOSUGGEST_ASYNC_FD=
}
#--------------------------------------------------------------------#