79980b00fb146437231c2a110ea49032b842c92c

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

fix(vi-mode): hide cursor-change logic behind `VI_MODE_SET_CURSOR` setting

Fixes #9570

Diff

 1diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
 2index fdf3ede73a9a0c4bf02f4ca8a95a2629621e479b..41faf2de02df88365b2fecd16242145420d83218 100644
 3--- a/plugins/vi-mode/README.md
 4+++ b/plugins/vi-mode/README.md
 5@@ -22,6 +22,13 @@ plugins=(... vi-mode)
 6   The default value is unset, unless `vi_mode_prompt_info` is used, in which case it'll
 7   automatically be set to `true`.
 8 
 9+- `VI_MODE_SET_CURSOR`: controls whether the cursor style is changed when switching
10+  to a different input mode. Set it to `true` to enable it (default: unset):
11+
12+  ```zsh
13+  VI_MODE_SET_CURSOR=true
14+  ```
15+
16 - `MODE_INDICATOR`: controls the string displayed when the shell is in normal mode.
17   See [Mode indicator](#mode-indicator) for details.
18 
19diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
20index f83ea76968d2ab4c5d93ce2851bab7ceae4c084a..e5b252d837d9e9e43eb4fdbed7177ba4a85019ff 100644
21--- a/plugins/vi-mode/vi-mode.plugin.zsh
22+++ b/plugins/vi-mode/vi-mode.plugin.zsh
23@@ -4,13 +4,21 @@
24 # This is especially true if the prompt does things like checking git status.
25 #
26 # Set to "true" to force the prompt to reset on each mode change.
27-# Set to "false" to force the prompt *not* to reset on each mode change.
28+# Unset or set to any other value to do the opposite.
29 #
30-# (The default is not to reset, unless we're showing the mode in RPS1).
31+# The default is not to reset, unless we're showing the mode in RPS1.
32 typeset -g VI_MODE_RESET_PROMPT_ON_MODE_CHANGE
33+# Control whether to change the cursor style on mode change.
34+#
35+# Set to "true" to change the cursor on each mode change.
36+# Unset or set to any other value to do the opposite.
37+typeset -g VI_MODE_SET_CURSOR
38+
39 typeset -g VI_KEYMAP=main
40 
41 function _vi-mode-set-cursor-shape-for-keymap() {
42+  [[ "$VI_MODE_SET_CURSOR" = true ]] || return
43+
44   # https://vt100.net/docs/vt510-rm/DECSCUSR
45   local _shape=0
46   case "${1:-${VI_KEYMAP:-main}}" in