Skip to content

Commit

Permalink
fix: repeat action in normal mode chomps lines above (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreytse committed Jul 9, 2023
1 parent 2ca0cf6 commit 6d7a673
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions zsh-vi-mode.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ function zvm_vi_opp_case() {
# Yank characters of the visual selection
function zvm_vi_yank() {
zvm_yank
zvm_exit_visual_mode
zvm_exit_visual_mode ${1:-true}
}

# Put cutbuffer after the cursor
Expand Down Expand Up @@ -1231,7 +1231,7 @@ function zvm_vi_change() {
fi

zvm_exit_visual_mode false
zvm_select_vi_mode $ZVM_MODE_INSERT
zvm_select_vi_mode $ZVM_MODE_INSERT ${1:-true}
}

# Change characters from cursor to the end of current line
Expand All @@ -1249,7 +1249,7 @@ function zvm_vi_change_eol() {
BUFFER="${BUFFER:0:$bpos}${BUFFER:$epos}"

zvm_reset_repeat_commands $ZVM_MODE c 0 $#CUTBUFFER
zvm_select_vi_mode $ZVM_MODE_INSERT
zvm_select_vi_mode $ZVM_MODE_INSERT ${1:-true}
}

# Default handler for unhandled key events
Expand Down Expand Up @@ -1750,7 +1750,7 @@ function zvm_range_handler() {
case "${keys}" in
c*) zvm_vi_change; cursor=;;
d*) zvm_vi_delete; cursor=;;
y*) zvm_vi_yank;;
y*) zvm_vi_yank; cursor=;;
[vV]*) cursor=;;
esac
Expand Down Expand Up @@ -2071,6 +2071,7 @@ function zvm_change_surround_text_object() {
# Repeat last change
function zvm_repeat_change() {
ZVM_REPEAT_MODE=true
ZVM_RESET_PROMPT_DISABLED=true

local cmd=${ZVM_REPEAT_COMMANDS[2]}

Expand All @@ -2086,6 +2087,7 @@ function zvm_repeat_change() {

zle redisplay

ZVM_RESET_PROMPT_DISABLED=false
ZVM_REPEAT_MODE=false
}

Expand Down Expand Up @@ -3039,6 +3041,11 @@ function zvm_reset_prompt() {
return
fi

# Return if reset prompt is disabled
if [[ $ZVM_RESET_PROMPT_DISABLED == true ]]; then
return
fi

local -i retval
if [[ -z "$rawfunc" ]]; then
zle .reset-prompt -- "$@"
Expand Down

0 comments on commit 6d7a673

Please sign in to comment.