mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2026-04-27 16:43:30 +02:00
Add feature detection
Checks whether `zpty` gives a file descriptor, which was not the case in older versions of zsh. Based on https://github.com/mafredri/zsh-async/blob/a4b2f81c966a00eeb38876d505d97423cc8addfd/async.zsh#L395-L401
This commit is contained in:
@@ -5,6 +5,7 @@ SRC_FILES := \
|
|||||||
$(SRC_DIR)/setup.zsh \
|
$(SRC_DIR)/setup.zsh \
|
||||||
$(SRC_DIR)/config.zsh \
|
$(SRC_DIR)/config.zsh \
|
||||||
$(SRC_DIR)/util.zsh \
|
$(SRC_DIR)/util.zsh \
|
||||||
|
$(SRC_DIR)/features.zsh \
|
||||||
$(SRC_DIR)/deprecated.zsh \
|
$(SRC_DIR)/deprecated.zsh \
|
||||||
$(SRC_DIR)/bind.zsh \
|
$(SRC_DIR)/bind.zsh \
|
||||||
$(SRC_DIR)/highlight.zsh \
|
$(SRC_DIR)/highlight.zsh \
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
#--------------------------------------------------------------------#
|
||||||
|
# Feature Detection #
|
||||||
|
#--------------------------------------------------------------------#
|
||||||
|
|
||||||
|
_zsh_autosuggest_feature_detect() {
|
||||||
|
typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD
|
||||||
|
typeset -h REPLY
|
||||||
|
|
||||||
|
zpty $ZSH_AUTOSUGGEST_PTY_NAME :
|
||||||
|
|
||||||
|
if (( REPLY )); then
|
||||||
|
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=1
|
||||||
|
else
|
||||||
|
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
zpty -d $ZSH_AUTOSUGGEST_PTY_NAME
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
_zsh_autosuggest_start() {
|
_zsh_autosuggest_start() {
|
||||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||||
|
|
||||||
|
_zsh_autosuggest_feature_detect
|
||||||
_zsh_autosuggest_check_deprecated_config
|
_zsh_autosuggest_check_deprecated_config
|
||||||
_zsh_autosuggest_bind_widgets
|
_zsh_autosuggest_bind_widgets
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,25 @@ _zsh_autosuggest_escape_command() {
|
|||||||
echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
|
echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------#
|
||||||
|
# Feature Detection #
|
||||||
|
#--------------------------------------------------------------------#
|
||||||
|
|
||||||
|
_zsh_autosuggest_feature_detect() {
|
||||||
|
typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD
|
||||||
|
typeset -h REPLY
|
||||||
|
|
||||||
|
zpty $ZSH_AUTOSUGGEST_PTY_NAME :
|
||||||
|
|
||||||
|
if (( REPLY )); then
|
||||||
|
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=1
|
||||||
|
else
|
||||||
|
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
zpty -d $ZSH_AUTOSUGGEST_PTY_NAME
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
# Handle Deprecated Variables/Widgets #
|
# Handle Deprecated Variables/Widgets #
|
||||||
#--------------------------------------------------------------------#
|
#--------------------------------------------------------------------#
|
||||||
@@ -570,6 +589,7 @@ add-zsh-hook precmd _zsh_autosuggest_async_recreate_pty
|
|||||||
_zsh_autosuggest_start() {
|
_zsh_autosuggest_start() {
|
||||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||||
|
|
||||||
|
_zsh_autosuggest_feature_detect
|
||||||
_zsh_autosuggest_check_deprecated_config
|
_zsh_autosuggest_check_deprecated_config
|
||||||
_zsh_autosuggest_bind_widgets
|
_zsh_autosuggest_bind_widgets
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user