4e513d72b9542b7b5079451e3380b4a98b0b7b56

Author
Jim Hester <james.f.hester@gmail.com>
Committer
Jim Hester <james.f.hester@gmail.com>
Date

Message

Fixes for vi-mode terminal overwriting bugs

fixes #387 and https://github.com/robbyrussell/oh-my-zsh/pull/1321#issuecomment-9959540
and other problems of prompt overwriting when people did not realize that it
was vi mode causing the problem.  Hat tip to sorin ionescu, as I took this code
from prezto

Diff

 1diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
 2index d29eb1dda85de0b8aa9416643166c5f4081d468b..e23bd3c54a1de214d635e2691a6ad0373c2f7404 100644
 3--- a/plugins/vi-mode/vi-mode.plugin.zsh
 4+++ b/plugins/vi-mode/vi-mode.plugin.zsh
 5@@ -1,8 +1,26 @@
 6-function zle-line-init zle-keymap-select {
 7+# Ensures that $terminfo values are valid and updates editor information when
 8+# the keymap changes.
 9+function zle-keymap-select zle-line-init zle-line-finish {
10+  # The terminal must be in application mode when ZLE is active for $terminfo
11+  # values to be valid.
12+  if (( $+terminfo[smkx] && $+terminfo[rmkx] )); then
13+    case "$0" in
14+      (zle-line-init)
15+        # Enable terminal application mode.
16+        echoti smkx
17+      ;;
18+      (zle-line-finish)
19+        # Disable terminal application mode.
20+        echoti rmkx
21+      ;;
22+    esac
23+  fi
24   zle reset-prompt
25+  zle -R
26 }
27 
28 zle -N zle-line-init
29+zle -N zle-line-finish
30 zle -N zle-keymap-select
31 
32 #changing mode clobbers the keybinds, so store the keybinds before and execute