Преглед изворни кода

cleanup: Switch to guard clause in accept widget handler

pull/488/head
Eric Freese пре 4 година
родитељ
комит
54d7a9a84c
2 измењених фајлова са 28 додато и 22 уклоњено
  1. +14
    -11
      src/widgets.zsh
  2. +14
    -11
      zsh-autosuggestions.zsh

+ 14
- 11
src/widgets.zsh Прегледај датотеку

@ -127,20 +127,23 @@ _zsh_autosuggest_accept() {
max_cursor_pos=$((max_cursor_pos - 1))
fi
if (( $CURSOR != $max_cursor_pos )); then
_zsh_autosuggest_invoke_original_widget $@
return
fi
# Only accept if the cursor is at the end of the buffer
if (( $CURSOR == $max_cursor_pos )); then
# Add the suggestion to the buffer
BUFFER="$BUFFER$POSTDISPLAY"
# Add the suggestion to the buffer
BUFFER="$BUFFER$POSTDISPLAY"
# Remove the suggestion
unset POSTDISPLAY
# Remove the suggestion
unset POSTDISPLAY
# Move the cursor to the end of the buffer
if [[ "$KEYMAP" = "vicmd" ]]; then
CURSOR=$(($#BUFFER - 1))
else
CURSOR=$#BUFFER
fi
# Move the cursor to the end of the buffer
if [[ "$KEYMAP" = "vicmd" ]]; then
CURSOR=$(($#BUFFER - 1))
else
CURSOR=$#BUFFER
fi
_zsh_autosuggest_invoke_original_widget $@

+ 14
- 11
zsh-autosuggestions.zsh Прегледај датотеку

@ -389,20 +389,23 @@ _zsh_autosuggest_accept() {
max_cursor_pos=$((max_cursor_pos - 1))
fi
if (( $CURSOR != $max_cursor_pos )); then
_zsh_autosuggest_invoke_original_widget $@
return
fi
# Only accept if the cursor is at the end of the buffer
if (( $CURSOR == $max_cursor_pos )); then
# Add the suggestion to the buffer
BUFFER="$BUFFER$POSTDISPLAY"
# Add the suggestion to the buffer
BUFFER="$BUFFER$POSTDISPLAY"
# Remove the suggestion
unset POSTDISPLAY
# Remove the suggestion
unset POSTDISPLAY
# Move the cursor to the end of the buffer
if [[ "$KEYMAP" = "vicmd" ]]; then
CURSOR=$(($#BUFFER - 1))
else
CURSOR=$#BUFFER
fi
# Move the cursor to the end of the buffer
if [[ "$KEYMAP" = "vicmd" ]]; then
CURSOR=$(($#BUFFER - 1))
else
CURSOR=$#BUFFER
fi
_zsh_autosuggest_invoke_original_widget $@

Loading…
Откажи
Сачувај