mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Add feature detection
Checks whether `zpty` gives a file descriptor, which was not the case in
older versions of zsh.
Based on a4b2f81c96/async.zsh (L395-L401)
This commit is contained in:
parent
3f57198d07
commit
78ba07179a
4 changed files with 41 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -5,6 +5,7 @@ SRC_FILES := \
|
|||
$(SRC_DIR)/setup.zsh \
|
||||
$(SRC_DIR)/config.zsh \
|
||||
$(SRC_DIR)/util.zsh \
|
||||
$(SRC_DIR)/features.zsh \
|
||||
$(SRC_DIR)/deprecated.zsh \
|
||||
$(SRC_DIR)/bind.zsh \
|
||||
$(SRC_DIR)/highlight.zsh \
|
||||
|
|
19
src/features.zsh
Normal file
19
src/features.zsh
Normal file
|
@ -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() {
|
||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||
|
||||
_zsh_autosuggest_feature_detect
|
||||
_zsh_autosuggest_check_deprecated_config
|
||||
_zsh_autosuggest_bind_widgets
|
||||
}
|
||||
|
|
|
@ -111,6 +111,25 @@ _zsh_autosuggest_escape_command() {
|
|||
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 #
|
||||
#--------------------------------------------------------------------#
|
||||
|
@ -570,6 +589,7 @@ add-zsh-hook precmd _zsh_autosuggest_async_recreate_pty
|
|||
_zsh_autosuggest_start() {
|
||||
add-zsh-hook -d precmd _zsh_autosuggest_start
|
||||
|
||||
_zsh_autosuggest_feature_detect
|
||||
_zsh_autosuggest_check_deprecated_config
|
||||
_zsh_autosuggest_bind_widgets
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue