Merge pull request #348 from zsh-users/fixes/no-zpty

Fixes/no zpty
This commit is contained in:
Eric Freese 2018-06-30 18:07:06 -06:00 committed by GitHub
commit 7c83775bc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 61 deletions

View file

@ -1,10 +1,8 @@
SRC_DIR := ./src
SRC_FILES := \
$(SRC_DIR)/setup.zsh \
$(SRC_DIR)/config.zsh \
$(SRC_DIR)/util.zsh \
$(SRC_DIR)/features.zsh \
$(SRC_DIR)/bind.zsh \
$(SRC_DIR)/highlight.zsh \
$(SRC_DIR)/widgets.zsh \

View file

@ -43,7 +43,7 @@ Set `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE` to configure the style that the suggestion
- `history`: Chooses the most recent match from history.
- `match_prev_cmd`: Like `history`, but chooses the most recent match whose preceding history item matches the most recently executed command ([more info](src/strategies/match_prev_cmd.zsh)). Note that this strategy won't work as expected with ZSH options that don't preserve the history order such as `HIST_IGNORE_ALL_DUPS` or `HIST_EXPIRE_DUPS_FIRST`.
- `completion`: (experimental) Chooses a suggestion based on what tab-completion would suggest.
- `completion`: (experimental) Chooses a suggestion based on what tab-completion would suggest. (requires `zpty` and `zutil` modules)
For example, setting `ZSH_AUTOSUGGEST_STRATEGY=(history completion)` will first try to find a suggestion from your history, but, if it can't find a match, will find a suggestion from the completion engine.

View file

@ -1,19 +0,0 @@
#--------------------------------------------------------------------#
# Feature Detection #
#--------------------------------------------------------------------#
_zsh_autosuggest_feature_detect_zpty_returns_fd() {
typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD
typeset -h REPLY
zpty zsh_autosuggest_feature_detect '{ zshexit() { kill -KILL $$; sleep 1 } }'
if (( REPLY )); then
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=1
else
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=0
fi
zpty -d zsh_autosuggest_feature_detect
}

View file

@ -1,10 +0,0 @@
#--------------------------------------------------------------------#
# Setup #
#--------------------------------------------------------------------#
# Precmd hooks for initializing the library and starting pty's
autoload -Uz add-zsh-hook
# Asynchronous suggestions are generated in a pty
zmodload zsh/zpty

View file

@ -17,4 +17,5 @@ _zsh_autosuggest_start() {
}
# Start the autosuggestion widgets on the next precmd
autoload -Uz add-zsh-hook
add-zsh-hook precmd _zsh_autosuggest_start

View file

@ -87,6 +87,8 @@ _zsh_autosuggest_capture_buffer() {
}
_zsh_autosuggest_capture_completion() {
zmodload zsh/zpty 2>/dev/null || return
typeset -g completion
local line REPLY

View file

@ -25,16 +25,6 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#--------------------------------------------------------------------#
# Setup #
#--------------------------------------------------------------------#
# Precmd hooks for initializing the library and starting pty's
autoload -Uz add-zsh-hook
# Asynchronous suggestions are generated in a pty
zmodload zsh/zpty
#--------------------------------------------------------------------#
# Global Configuration Variables #
#--------------------------------------------------------------------#
@ -122,25 +112,6 @@ _zsh_autosuggest_escape_command() {
echo -E "${1//(#m)[\"\'\\()\[\]|*?~]/\\$MATCH}"
}
#--------------------------------------------------------------------#
# Feature Detection #
#--------------------------------------------------------------------#
_zsh_autosuggest_feature_detect_zpty_returns_fd() {
typeset -g _ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD
typeset -h REPLY
zpty zsh_autosuggest_feature_detect '{ zshexit() { kill -KILL $$; sleep 1 } }'
if (( REPLY )); then
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=1
else
_ZSH_AUTOSUGGEST_ZPTY_RETURNS_FD=0
fi
zpty -d zsh_autosuggest_feature_detect
}
#--------------------------------------------------------------------#
# Widget Helpers #
#--------------------------------------------------------------------#
@ -586,6 +557,8 @@ _zsh_autosuggest_capture_buffer() {
}
_zsh_autosuggest_capture_completion() {
zmodload zsh/zpty 2>/dev/null || return
typeset -g completion
local line REPLY
@ -799,4 +772,5 @@ _zsh_autosuggest_start() {
}
# Start the autosuggestion widgets on the next precmd
autoload -Uz add-zsh-hook
add-zsh-hook precmd _zsh_autosuggest_start