From b609aa0e6c981f2039d777687cb01a84587f6edc Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Thu, 20 Sep 2012 08:03:09 -0400 Subject: Fix to restore bindings after switching to vi-mode the vi-mode plugin destroys any bindings made before it is sourced due to the 'bindkey -v' call to switch to using vi-mode. This patch saves the bindings before invoking 'bindkey -v' then rebinds them afterwards, this fixes a number of outstanding issues due to people using vi-mode and having things in oh-my-zsh break due to the bindings being destroyed --- plugins/vi-mode/vi-mode.plugin.zsh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index c47ab7211..d29eb1dda 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -5,7 +5,12 @@ function zle-line-init zle-keymap-select { zle -N zle-line-init zle -N zle-keymap-select +#changing mode clobbers the keybinds, so store the keybinds before and execute +#them after +binds=`bindkey -L` bindkey -v +for bind in ${(@f)binds}; do eval $bind; done +unset binds # if mode indicator wasn't setup by theme, define default if [[ "$MODE_INDICATOR" == "" ]]; then -- cgit v1.2.3-70-g09d2 From 4e513d72b9542b7b5079451e3380b4a98b0b7b56 Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Fri, 2 Nov 2012 11:06:32 -0400 Subject: 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 --- plugins/vi-mode/vi-mode.plugin.zsh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index d29eb1dda..e23bd3c54 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -1,8 +1,26 @@ -function zle-line-init zle-keymap-select { +# Ensures that $terminfo values are valid and updates editor information when +# the keymap changes. +function zle-keymap-select zle-line-init zle-line-finish { + # The terminal must be in application mode when ZLE is active for $terminfo + # values to be valid. + if (( $+terminfo[smkx] && $+terminfo[rmkx] )); then + case "$0" in + (zle-line-init) + # Enable terminal application mode. + echoti smkx + ;; + (zle-line-finish) + # Disable terminal application mode. + echoti rmkx + ;; + esac + fi zle reset-prompt + zle -R } zle -N zle-line-init +zle -N zle-line-finish zle -N zle-keymap-select #changing mode clobbers the keybinds, so store the keybinds before and execute -- cgit v1.2.3-70-g09d2 From 53854754e0d052c41587c7d84b9be7868f31bfe8 Mon Sep 17 00:00:00 2001 From: Max Bane Date: Wed, 28 Nov 2012 02:02:58 -0500 Subject: Revert "Fix to restore bindings after switching to vi-mode" This reverts commit b609aa0e6c981f2039d777687cb01a84587f6edc -- this commit was a bad idea, because it makes vi-mode very difficult to use. The default `bindkey` keybindings are NOT MEANT to coexist with `bindkey -v` Vi mode; that's why `bindkey -v` clears them in the first place! Restoring all of the default keybindings after enabling Vi mode, the way the reverted commit did, causes many collisions between those default keybindings that begin with ESC and the command-mode-initiating ESC of Vi mode. See Issue 1438 of robbyrussell/oh-my-zsh. If people have custom keybindings, they should create them in their ~/.zshrc AFTER enabling the vi-mode plugin and sourcing oh-my-zsh.sh. # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: plugins/vi-mode/vi-mode.plugin.zsh # --- plugins/vi-mode/vi-mode.plugin.zsh | 5 ----- 1 file changed, 5 deletions(-) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index d29eb1dda..c47ab7211 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -5,12 +5,7 @@ function zle-line-init zle-keymap-select { zle -N zle-line-init zle -N zle-keymap-select -#changing mode clobbers the keybinds, so store the keybinds before and execute -#them after -binds=`bindkey -L` bindkey -v -for bind in ${(@f)binds}; do eval $bind; done -unset binds # if mode indicator wasn't setup by theme, define default if [[ "$MODE_INDICATOR" == "" ]]; then -- cgit v1.2.3-70-g09d2 From 003dd8f4b68062b7fd5e4e1725264189ee56e28a Mon Sep 17 00:00:00 2001 From: Greg Berenfield Date: Wed, 2 Jan 2013 16:20:22 -0500 Subject: fix for Issue 1479 --- plugins/vi-mode/vi-mode.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index f91be70e4..27fb47c97 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -7,11 +7,11 @@ function zle-keymap-select zle-line-init zle-line-finish { case "$0" in (zle-line-init) # Enable terminal application mode. - echoti smkx + printf '%s' ${terminfo[smkx]} ;; (zle-line-finish) # Disable terminal application mode. - echoti rmkx + printf '%s' ${terminfo[rmkx]} ;; esac fi -- cgit v1.2.3-70-g09d2 From 93c90a6bf5817d09e978bd720eaa7f9be971a1c6 Mon Sep 17 00:00:00 2001 From: Greg Berenfield Date: Wed, 2 Jan 2013 19:14:57 -0500 Subject: Fix the fix for Issue #1479 --- plugins/vi-mode/vi-mode.plugin.zsh | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'plugins/vi-mode') diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 27fb47c97..a06100472 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -3,18 +3,13 @@ function zle-keymap-select zle-line-init zle-line-finish { # The terminal must be in application mode when ZLE is active for $terminfo # values to be valid. - if (( $+terminfo[smkx] && $+terminfo[rmkx] )); then - case "$0" in - (zle-line-init) - # Enable terminal application mode. - printf '%s' ${terminfo[smkx]} - ;; - (zle-line-finish) - # Disable terminal application mode. - printf '%s' ${terminfo[rmkx]} - ;; - esac + if (( ${+terminfo[smkx]} )); then + printf '%s' ${terminfo[smkx]} fi + if (( ${+terminfo[rmkx]} )); then + printf '%s' ${terminfo[rmkx]} + fi + zle reset-prompt zle -R } -- cgit v1.2.3-70-g09d2