mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2026-11-11 11:01:51 -05:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70517a6dfd | ||
|
|
4e7ceb9f32 |
+12
-2
@@ -44,7 +44,6 @@ _zsh_autosuggest_async_request() {
|
|||||||
|
|
||||||
# There's a weird bug here where ^C stops working unless we force a fork
|
# There's a weird bug here where ^C stops working unless we force a fork
|
||||||
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
||||||
autoload -Uz is-at-least
|
|
||||||
is-at-least 5.8 || command true
|
is-at-least 5.8 || command true
|
||||||
|
|
||||||
# Read the pid from the child process
|
# Read the pid from the child process
|
||||||
@@ -65,7 +64,7 @@ _zsh_autosuggest_async_response() {
|
|||||||
if [[ -z "$2" || "$2" == "hup" ]]; then
|
if [[ -z "$2" || "$2" == "hup" ]]; then
|
||||||
# Read everything from the fd and give it as a suggestion
|
# Read everything from the fd and give it as a suggestion
|
||||||
IFS='' read -rd '' -u $1 suggestion
|
IFS='' read -rd '' -u $1 suggestion
|
||||||
zle autosuggest-suggest -- "$suggestion"
|
_zsh_autosuggest_async_suggest "$suggestion"
|
||||||
|
|
||||||
# Close the fd
|
# Close the fd
|
||||||
exec {1}<&-
|
exec {1}<&-
|
||||||
@@ -74,3 +73,14 @@ _zsh_autosuggest_async_response() {
|
|||||||
# Always remove the handler
|
# Always remove the handler
|
||||||
zle -F "$1"
|
zle -F "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_zsh_autosuggest_async_suggest() {
|
||||||
|
# Before 5.9, async suggestions break widgets that rely on LASTWIDGET
|
||||||
|
# such as copy-earlier-word and {up,down}-line-or-beginning-search. In
|
||||||
|
# 5.9, a flag was added to `zle` that will skip setting LASTWIDGET so
|
||||||
|
# that those widgets that depend on it will continue to work
|
||||||
|
# See https://www.zsh.org/mla/workers/2020/msg00824.html
|
||||||
|
local nolast
|
||||||
|
is-at-least 5.9 && nolast=supported
|
||||||
|
zle autosuggest-suggest ${=nolast:+-f nolast} -- "$1"
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
|||||||
history-search-backward
|
history-search-backward
|
||||||
history-beginning-search-forward
|
history-beginning-search-forward
|
||||||
history-beginning-search-backward
|
history-beginning-search-backward
|
||||||
history-beginning-search-forward-end
|
|
||||||
history-beginning-search-backward-end
|
|
||||||
history-substring-search-up
|
history-substring-search-up
|
||||||
history-substring-search-down
|
history-substring-search-down
|
||||||
up-line-or-beginning-search
|
up-line-or-beginning-search
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
0=${(%):-%N}
|
|
||||||
source ${0:A:h}/zsh-autosuggestions.zsh
|
source ${0:A:h}/zsh-autosuggestions.zsh
|
||||||
|
|||||||
+12
-4
@@ -54,8 +54,6 @@ typeset -g ZSH_AUTOSUGGEST_ORIGINAL_WIDGET_PREFIX=autosuggest-orig-
|
|||||||
history-search-backward
|
history-search-backward
|
||||||
history-beginning-search-forward
|
history-beginning-search-forward
|
||||||
history-beginning-search-backward
|
history-beginning-search-backward
|
||||||
history-beginning-search-forward-end
|
|
||||||
history-beginning-search-backward-end
|
|
||||||
history-substring-search-up
|
history-substring-search-up
|
||||||
history-substring-search-down
|
history-substring-search-down
|
||||||
up-line-or-beginning-search
|
up-line-or-beginning-search
|
||||||
@@ -801,7 +799,6 @@ _zsh_autosuggest_async_request() {
|
|||||||
|
|
||||||
# There's a weird bug here where ^C stops working unless we force a fork
|
# There's a weird bug here where ^C stops working unless we force a fork
|
||||||
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
# See https://github.com/zsh-users/zsh-autosuggestions/issues/364
|
||||||
autoload -Uz is-at-least
|
|
||||||
is-at-least 5.8 || command true
|
is-at-least 5.8 || command true
|
||||||
|
|
||||||
# Read the pid from the child process
|
# Read the pid from the child process
|
||||||
@@ -822,7 +819,7 @@ _zsh_autosuggest_async_response() {
|
|||||||
if [[ -z "$2" || "$2" == "hup" ]]; then
|
if [[ -z "$2" || "$2" == "hup" ]]; then
|
||||||
# Read everything from the fd and give it as a suggestion
|
# Read everything from the fd and give it as a suggestion
|
||||||
IFS='' read -rd '' -u $1 suggestion
|
IFS='' read -rd '' -u $1 suggestion
|
||||||
zle autosuggest-suggest -- "$suggestion"
|
_zsh_autosuggest_async_suggest "$suggestion"
|
||||||
|
|
||||||
# Close the fd
|
# Close the fd
|
||||||
exec {1}<&-
|
exec {1}<&-
|
||||||
@@ -832,6 +829,17 @@ _zsh_autosuggest_async_response() {
|
|||||||
zle -F "$1"
|
zle -F "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_zsh_autosuggest_async_suggest() {
|
||||||
|
# Before 5.9, async suggestions break widgets that rely on LASTWIDGET
|
||||||
|
# such as copy-earlier-word and {up,down}-line-or-beginning-search. In
|
||||||
|
# 5.9, a flag was added to `zle` that will skip setting LASTWIDGET so
|
||||||
|
# that those widgets that depend on it will continue to work
|
||||||
|
# See https://www.zsh.org/mla/workers/2020/msg00824.html
|
||||||
|
local nolast
|
||||||
|
is-at-least 5.9 && nolast=supported
|
||||||
|
zle autosuggest-suggest ${=nolast:+-f nolast} -- "$1"
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
# Start #
|
# Start #
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
|
|||||||
Reference in New Issue
Block a user