Skip to content

Commit

Permalink
fix: unexpected behavior of [cdy][hl] (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreytse committed Apr 1, 2021
1 parent 4e4d248 commit 1d8698c
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions zsh-vi-mode.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ function zvm_range_handler() {
navkey="${keys:1:-1}e"
elif [[ $keys =~ '^c([1-9][0-9]*)?E$' ]]; then
navkey="${keys:1:-1}E"
elif [[ $keys =~ '^[cdy]([1-9][0-9]*)?[bB]$' ]]; then
elif [[ $keys =~ '^[cdy]([1-9][0-9]*)?[hbB]$' ]]; then
MARK=$((MARK-1))
navkey="${keys:1}"
elif [[ $keys =~ '^[cdy]([1-9][0-9]*)?[FT].?$' ]]; then
Expand Down Expand Up @@ -1557,19 +1557,20 @@ function zvm_range_handler() {
fi

# Post navigation handling
case "${keys}" in
[cdy]*i[wW]) cursor=$MARK;;
[cdy]*a[wW]) cursor=$MARK;;
[dy]*[wW])
if [[ $keys =~ '^[cdy]([1-9][0-9]*)?[ia][wW]$' ]]; then
cursor=$MARK
elif [[ $keys =~ '[dy]([1-9][0-9]*)?[wW]' ]]; then
CURSOR=$((CURSOR-1))
# If the CURSOR is at the newline character, we should
# move backward a character
if [[ "${BUFFER:$CURSOR:1}" == $'\n' ]]; then
CURSOR=$((CURSOR-1))
# If the CURSOR is at the newline character, we should
# move backward a character
if [[ "${BUFFER:$CURSOR:1}" == $'\n' ]]; then
CURSOR=$((CURSOR-1))
fi
;;
[bftBFT]) cursor=$CURSOR;;
esac
fi
elif [[ $keys =~ '^[cdy]([1-9][0-9]*)?l$' ]]; then
CURSOR=$((CURSOR-1))
else
cursor=$CURSOR
fi

# Handle operation
case "${keys}" in
Expand Down

0 comments on commit 1d8698c

Please sign in to comment.