fix(vi-mode): fix keymap indicator on zle-line-finish (#9620)

* Update VI_KEYMAP on zle-line-finish.  Fixes next prompt draw.

* Also fix vi-mode prompt redraw in case previous prompt was canceled

* Do not redraw fix prompt if VI_MODE_RESET_PROMPT_ON_MODE_CHANGE is unset

* Use a local variable instead of global in function
This commit is contained in:
CrispyConductor 2021-03-15 18:32:49 -04:00 committed by GitHub
parent e5d206c8c8
commit 3f34ce4da4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,13 +50,17 @@ zle -N zle-keymap-select
# These "echoti" statements were originally set in lib/key-bindings.zsh # These "echoti" statements were originally set in lib/key-bindings.zsh
# Not sure the best way to extend without overriding. # Not sure the best way to extend without overriding.
function zle-line-init() { function zle-line-init() {
local prev_vi_keymap
prev_vi_keymap="${VI_KEYMAP:-}"
typeset -g VI_KEYMAP=main typeset -g VI_KEYMAP=main
[[ "$prev_vi_keymap" != 'main' ]] && [[ "${VI_MODE_RESET_PROMPT_ON_MODE_CHANGE:-}" = true ]] && zle reset-prompt
(( ! ${+terminfo[smkx]} )) || echoti smkx (( ! ${+terminfo[smkx]} )) || echoti smkx
_vi-mode-set-cursor-shape-for-keymap "${VI_KEYMAP}" _vi-mode-set-cursor-shape-for-keymap "${VI_KEYMAP}"
} }
zle -N zle-line-init zle -N zle-line-init
function zle-line-finish() { function zle-line-finish() {
typeset -g VI_KEYMAP=main
(( ! ${+terminfo[rmkx]} )) || echoti rmkx (( ! ${+terminfo[rmkx]} )) || echoti rmkx
_vi-mode-set-cursor-shape-for-keymap default _vi-mode-set-cursor-shape-for-keymap default
} }