Skip to content

Commit

Permalink
Make cursor styling more robust; disable it on Konsole
Browse files Browse the repository at this point in the history
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
  • Loading branch information
softmoth committed Aug 16, 2018
1 parent a920cb4 commit 68f601b
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions zsh-vim-mode.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -532,35 +532,31 @@ 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
fi
}

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
Expand Down

0 comments on commit 68f601b

Please sign in to comment.