POSIX_IDENTIFIERS compatibility

This commit is contained in:
KittoKin 2020-09-05 03:18:14 -04:00
parent ae315ded4d
commit e3333e8ac0
5 changed files with 33 additions and 33 deletions

View File

@ -43,7 +43,7 @@ shared_examples 'special characters' do
wait_for { session.content }.to eq('echo "#yolo"') wait_for { session.content }.to eq('echo "#yolo"')
end end
with_history('echo "#foo"', 'echo $#abc') do with_history('echo "#foo"', 'echo ${#abc}') do
session.send_string('echo "#') session.send_string('echo "#')
wait_for { session.content }.to eq('echo "#foo"') wait_for { session.content }.to eq('echo "#foo"')
end end

View File

@ -17,8 +17,8 @@ _zsh_autosuggest_highlight_reset() {
_zsh_autosuggest_highlight_apply() { _zsh_autosuggest_highlight_apply() {
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
if (( $#POSTDISPLAY )); then if (( ${#POSTDISPLAY} )); then
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE" typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="${#BUFFER} $((${#BUFFER} + ${#POSTDISPLAY})) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE"
region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT") region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT")
else else
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT

View File

@ -21,7 +21,7 @@ _zsh_autosuggest_capture_completion_widget() {
comppostfuncs=(_zsh_autosuggest_capture_postcompletion) comppostfuncs=(_zsh_autosuggest_capture_postcompletion)
# Only capture completions at the end of the buffer # Only capture completions at the end of the buffer
CURSOR=$#BUFFER CURSOR=${#BUFFER}
# Run the original widget wrapping `.complete-word` so we don't # Run the original widget wrapping `.complete-word` so we don't
# recursively try to fetch suggestions, since our pty is forked # recursively try to fetch suggestions, since our pty is forked

View File

@ -13,7 +13,7 @@ _zsh_autosuggest_disable() {
_zsh_autosuggest_enable() { _zsh_autosuggest_enable() {
unset _ZSH_AUTOSUGGEST_DISABLED unset _ZSH_AUTOSUGGEST_DISABLED
if (( $#BUFFER )); then if (( ${#BUFFER} )); then
_zsh_autosuggest_fetch _zsh_autosuggest_fetch
fi fi
} }
@ -62,12 +62,12 @@ _zsh_autosuggest_modify() {
fi fi
# Optimize if manually typing in the suggestion # Optimize if manually typing in the suggestion
if (( $#BUFFER > $#orig_buffer )); then if (( ${#BUFFER} > ${#orig_buffer} )); then
local added=${BUFFER#$orig_buffer} local added=${BUFFER#$orig_buffer}
# If the string added matches the beginning of the postdisplay # If the string added matches the beginning of the postdisplay
if [[ "$added" = "${orig_postdisplay:0:$#added}" ]]; then if [[ "$added" = "${orig_postdisplay:0:${#added}}" ]]; then
POSTDISPLAY="${orig_postdisplay:$#added}" POSTDISPLAY="${orig_postdisplay:${#added}}"
return $retval return $retval
fi fi
fi fi
@ -84,8 +84,8 @@ _zsh_autosuggest_modify() {
fi fi
# Get a new suggestion if the buffer is not empty after modification # Get a new suggestion if the buffer is not empty after modification
if (( $#BUFFER > 0 )); then if (( ${#BUFFER} > 0 )); then
if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( $#BUFFER <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( ${#BUFFER} <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then
_zsh_autosuggest_fetch _zsh_autosuggest_fetch
fi fi
fi fi
@ -110,7 +110,7 @@ _zsh_autosuggest_suggest() {
local suggestion="$1" local suggestion="$1"
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then if [[ -n "$suggestion" ]] && (( ${#BUFFER} )); then
POSTDISPLAY="${suggestion#$BUFFER}" POSTDISPLAY="${suggestion#$BUFFER}"
else else
unset POSTDISPLAY unset POSTDISPLAY
@ -119,7 +119,7 @@ _zsh_autosuggest_suggest() {
# Accept the entire suggestion # Accept the entire suggestion
_zsh_autosuggest_accept() { _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 # When vicmd keymap is active, the cursor can't move all the way
# to the end of the buffer # 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 # If we're not in a valid state to accept a suggestion, just run the
# original widget and bail out # original widget and bail out
if (( $CURSOR != $max_cursor_pos || !$#POSTDISPLAY )); then if (( $CURSOR != $max_cursor_pos || !${#POSTDISPLAY} )); then
_zsh_autosuggest_invoke_original_widget $@ _zsh_autosuggest_invoke_original_widget $@
return return
fi fi
@ -148,9 +148,9 @@ _zsh_autosuggest_accept() {
# Move the cursor to the end of the buffer # Move the cursor to the end of the buffer
if [[ "$KEYMAP" = "vicmd" ]]; then if [[ "$KEYMAP" = "vicmd" ]]; then
CURSOR=$(($#BUFFER - 1)) CURSOR=$((${#BUFFER} - 1))
else else
CURSOR=$#BUFFER CURSOR=${#BUFFER}
fi fi
return $retval return $retval
@ -190,9 +190,9 @@ _zsh_autosuggest_partial_accept() {
fi fi
# If we've moved past the end of the original buffer # 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 # 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 # Clip the buffer at the cursor
BUFFER="${BUFFER[1,$cursor_loc]}" BUFFER="${BUFFER[1,$cursor_loc]}"

View File

@ -253,8 +253,8 @@ _zsh_autosuggest_highlight_reset() {
_zsh_autosuggest_highlight_apply() { _zsh_autosuggest_highlight_apply() {
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
if (( $#POSTDISPLAY )); then if (( ${#POSTDISPLAY} )); then
typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="$#BUFFER $(($#BUFFER + $#POSTDISPLAY)) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE" typeset -g _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT="${#BUFFER} $((${#BUFFER} + ${#POSTDISPLAY})) $ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE"
region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT") region_highlight+=("$_ZSH_AUTOSUGGEST_LAST_HIGHLIGHT")
else else
unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT unset _ZSH_AUTOSUGGEST_LAST_HIGHLIGHT
@ -275,7 +275,7 @@ _zsh_autosuggest_disable() {
_zsh_autosuggest_enable() { _zsh_autosuggest_enable() {
unset _ZSH_AUTOSUGGEST_DISABLED unset _ZSH_AUTOSUGGEST_DISABLED
if (( $#BUFFER )); then if (( ${#BUFFER} )); then
_zsh_autosuggest_fetch _zsh_autosuggest_fetch
fi fi
} }
@ -324,12 +324,12 @@ _zsh_autosuggest_modify() {
fi fi
# Optimize if manually typing in the suggestion # Optimize if manually typing in the suggestion
if (( $#BUFFER > $#orig_buffer )); then if (( ${#BUFFER} > ${#orig_buffer} )); then
local added=${BUFFER#$orig_buffer} local added=${BUFFER#$orig_buffer}
# If the string added matches the beginning of the postdisplay # If the string added matches the beginning of the postdisplay
if [[ "$added" = "${orig_postdisplay:0:$#added}" ]]; then if [[ "$added" = "${orig_postdisplay:0:${#added}}" ]]; then
POSTDISPLAY="${orig_postdisplay:$#added}" POSTDISPLAY="${orig_postdisplay:${#added}}"
return $retval return $retval
fi fi
fi fi
@ -346,8 +346,8 @@ _zsh_autosuggest_modify() {
fi fi
# Get a new suggestion if the buffer is not empty after modification # Get a new suggestion if the buffer is not empty after modification
if (( $#BUFFER > 0 )); then if (( ${#BUFFER} > 0 )); then
if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( $#BUFFER <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then if [[ -z "$ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" ]] || (( ${#BUFFER} <= $ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE )); then
_zsh_autosuggest_fetch _zsh_autosuggest_fetch
fi fi
fi fi
@ -372,7 +372,7 @@ _zsh_autosuggest_suggest() {
local suggestion="$1" local suggestion="$1"
if [[ -n "$suggestion" ]] && (( $#BUFFER )); then if [[ -n "$suggestion" ]] && (( ${#BUFFER} )); then
POSTDISPLAY="${suggestion#$BUFFER}" POSTDISPLAY="${suggestion#$BUFFER}"
else else
unset POSTDISPLAY unset POSTDISPLAY
@ -381,7 +381,7 @@ _zsh_autosuggest_suggest() {
# Accept the entire suggestion # Accept the entire suggestion
_zsh_autosuggest_accept() { _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 # When vicmd keymap is active, the cursor can't move all the way
# to the end of the buffer # to the end of the buffer
@ -391,7 +391,7 @@ _zsh_autosuggest_accept() {
# If we're not in a valid state to accept a suggestion, just run the # If we're not in a valid state to accept a suggestion, just run the
# original widget and bail out # original widget and bail out
if (( $CURSOR != $max_cursor_pos || !$#POSTDISPLAY )); then if (( $CURSOR != $max_cursor_pos || !${#POSTDISPLAY} )); then
_zsh_autosuggest_invoke_original_widget $@ _zsh_autosuggest_invoke_original_widget $@
return return
fi fi
@ -410,9 +410,9 @@ _zsh_autosuggest_accept() {
# Move the cursor to the end of the buffer # Move the cursor to the end of the buffer
if [[ "$KEYMAP" = "vicmd" ]]; then if [[ "$KEYMAP" = "vicmd" ]]; then
CURSOR=$(($#BUFFER - 1)) CURSOR=$((${#BUFFER} - 1))
else else
CURSOR=$#BUFFER CURSOR=${#BUFFER}
fi fi
return $retval return $retval
@ -452,9 +452,9 @@ _zsh_autosuggest_partial_accept() {
fi fi
# If we've moved past the end of the original buffer # 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 # 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 # Clip the buffer at the cursor
BUFFER="${BUFFER[1,$cursor_loc]}" BUFFER="${BUFFER[1,$cursor_loc]}"
@ -517,7 +517,7 @@ _zsh_autosuggest_capture_completion_widget() {
comppostfuncs=(_zsh_autosuggest_capture_postcompletion) comppostfuncs=(_zsh_autosuggest_capture_postcompletion)
# Only capture completions at the end of the buffer # Only capture completions at the end of the buffer
CURSOR=$#BUFFER CURSOR=${#BUFFER}
# Run the original widget wrapping `.complete-word` so we don't # Run the original widget wrapping `.complete-word` so we don't
# recursively try to fetch suggestions, since our pty is forked # recursively try to fetch suggestions, since our pty is forked