mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-12-08 15:32:31 +01:00
POSIX_IDENTIFIERS compatibility
This commit is contained in:
parent
ae315ded4d
commit
e3333e8ac0
5 changed files with 33 additions and 33 deletions
|
|
@ -13,7 +13,7 @@ _zsh_autosuggest_disable() {
|
|||
_zsh_autosuggest_enable() {
|
||||
unset _ZSH_AUTOSUGGEST_DISABLED
|
||||
|
||||
if (( $#BUFFER )); then
|
||||
if (( ${#BUFFER} )); then
|
||||
_zsh_autosuggest_fetch
|
||||
fi
|
||||
}
|
||||
|
|
@ -62,12 +62,12 @@ _zsh_autosuggest_modify() {
|
|||
fi
|
||||
|
||||
# Optimize if manually typing in the suggestion
|
||||
if (( $#BUFFER > $#orig_buffer )); then
|
||||
if (( ${#BUFFER} > ${#orig_buffer} )); then
|
||||
local added=${BUFFER#$orig_buffer}
|
||||
|
||||
# If the string added matches the beginning of the postdisplay
|
||||
if [[ "$added" = "${orig_postdisplay:0:$#added}" ]]; then
|
||||
POSTDISPLAY="${orig_postdisplay:$#added}"
|
||||
if [[ "$added" = "${orig_postdisplay:0:${#added}}" ]]; then
|
||||
POSTDISPLAY="${orig_postdisplay:${#added}}"
|
||||
return $retval
|
||||
fi
|
||||
fi
|
||||
|
|
@ -84,8 +84,8 @@ _zsh_autosuggest_modify() {
|
|||
fi
|
||||
|
||||
# Get a new suggestion if the buffer is not empty after modification
|
||||
if (( $#BUFFER > 0 )); then
|
||||
if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( $#BUFFER <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then
|
||||
if (( ${#BUFFER} > 0 )); then
|
||||
if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( ${#BUFFER} <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then
|
||||
_zsh_autosuggest_fetch
|
||||
fi
|
||||
fi
|
||||
|
|
@ -110,7 +110,7 @@ _zsh_autosuggest_suggest() {
|
|||
|
||||
local suggestion="$1"
|
||||
|
||||
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then
|
||||
if [[ -n "$suggestion" ]] && (( ${#BUFFER} )); then
|
||||
POSTDISPLAY="${suggestion#$BUFFER}"
|
||||
else
|
||||
unset POSTDISPLAY
|
||||
|
|
@ -119,7 +119,7 @@ _zsh_autosuggest_suggest() {
|
|||
|
||||
# Accept the entire suggestion
|
||||
_zsh_autosuggest_accept() {
|
||||
local -i retval max_cursor_pos=$#BUFFER
|
||||
local -i retval max_cursor_pos=${#BUFFER}
|
||||
|
||||
# When vicmd keymap is active, the cursor can't move all the way
|
||||
# to the end of the buffer
|
||||
|
|
@ -129,7 +129,7 @@ _zsh_autosuggest_accept() {
|
|||
|
||||
# If we're not in a valid state to accept a suggestion, just run the
|
||||
# original widget and bail out
|
||||
if (( $CURSOR != $max_cursor_pos || !$#POSTDISPLAY )); then
|
||||
if (( $CURSOR != $max_cursor_pos || !${#POSTDISPLAY} )); then
|
||||
_zsh_autosuggest_invoke_original_widget $@
|
||||
return
|
||||
fi
|
||||
|
|
@ -148,9 +148,9 @@ _zsh_autosuggest_accept() {
|
|||
|
||||
# Move the cursor to the end of the buffer
|
||||
if [[ "$KEYMAP" = "vicmd" ]]; then
|
||||
CURSOR=$(($#BUFFER - 1))
|
||||
CURSOR=$((${#BUFFER} - 1))
|
||||
else
|
||||
CURSOR=$#BUFFER
|
||||
CURSOR=${#BUFFER}
|
||||
fi
|
||||
|
||||
return $retval
|
||||
|
|
@ -190,9 +190,9 @@ _zsh_autosuggest_partial_accept() {
|
|||
fi
|
||||
|
||||
# If we've moved past the end of the original buffer
|
||||
if (( $cursor_loc > $#original_buffer )); then
|
||||
if (( $cursor_loc > ${#original_buffer} )); then
|
||||
# Set POSTDISPLAY to text right of the cursor
|
||||
POSTDISPLAY="${BUFFER[$(($cursor_loc + 1)),$#BUFFER]}"
|
||||
POSTDISPLAY="${BUFFER[$(($cursor_loc + 1)),${#BUFFER}]}"
|
||||
|
||||
# Clip the buffer at the cursor
|
||||
BUFFER="${BUFFER[1,$cursor_loc]}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue