From 68f601bdc8c28dd656882214db87a2a861bb6125 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 16 Aug 2018 11:16:11 -0600 Subject: [PATCH] Make cursor styling more robust; disable it on Konsole Minimally fixes #6, by disabling cursor styling on Konsole. A complete fix needs to use the Konsole-specific codes, possibly versioned to take the upcoming fix (in 18.08?) for Konsole [bug 347323][1]. This change also avoids printing the cursor-styling sequences at all if no cursor style is defined. Previously, the default style was set regardless. This will ensure that any similar problems with other terminals will only show up if the user requests cursor styling explicitly. 1: https://bugs.kde.org/show_bug.cgi?id=347323 --- zsh-vim-mode.plugin.zsh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/zsh-vim-mode.plugin.zsh b/zsh-vim-mode.plugin.zsh index d521bac..4ce65ef 100644 --- a/zsh-vim-mode.plugin.zsh +++ b/zsh-vim-mode.plugin.zsh @@ -532,7 +532,9 @@ vim-mode-set-cursor-style() { || -n $MODE_CURSOR_SEARCH ]] then case $keymap in - vicmd) set-terminal-cursor-style ${=MODE_CURSOR_VICMD} ;; + DEFAULT) set-terminal-cursor-style ;; + vicmd|visual|vline) + set-terminal-cursor-style ${=MODE_CURSOR_VICMD} ;; isearch) set-terminal-cursor-style ${=MODE_CURSOR_SEARCH} ;; main|viins|*) set-terminal-cursor-style ${=MODE_CURSOR_VIINS} ;; esac @@ -540,27 +542,21 @@ vim-mode-set-cursor-style() { } vim-mode-cursor-init-hook() { - vim-mode-set-cursor-style '' + vim-mode-set-cursor-style viins } vim-mode-cursor-finish-hook() { - set-terminal-cursor-style + vim-mode-set-cursor-style DEFAULT } -case $TERM in - # TODO Query terminal capabilities with escape sequences - # TODO Support linux, iTerm2, and others? - # http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes - - dumb | linux | eterm-color ) - ;; +if [[ $TERM = (dumb|linux|eterm-color) ]] || (( $+KONSOLE_PROFILE_NAME )); then + : +else + vim_mode_keymap_funcs+=vim-mode-set-cursor-style - * ) - vim_mode_keymap_funcs+=vim-mode-set-cursor-style - add-zsh-hook precmd vim-mode-cursor-init-hook - add-zle-hook-widget line-finish vim-mode-cursor-finish-hook - ;; -esac + add-zsh-hook precmd vim-mode-cursor-init-hook + add-zle-hook-widget line-finish vim-mode-cursor-finish-hook +fi # Restore shell option 'aliases'. This must be the last thing here. if [[ $_vim_mode_shopt_aliases = 1 ]]; then