Skip to content

Commit

Permalink
Stop treating tmux special.
Browse files Browse the repository at this point in the history
It's not been necessary to use the tmux-escaping for a while, and causes
problems like we see in #40.  Lets flip things around.  If your tmux
needs it, then enable it with `g:togglecursor_enable_tmux_escaping`.
  • Loading branch information
jszakmeister committed Dec 5, 2020
1 parent f3490da commit 4c9ddf6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
18 changes: 4 additions & 14 deletions doc/togglecursor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,11 @@ g:togglecursor_force Force togglecursor to use a particular mechanism to
uses the DESCCUSR escape sequence) and 'cursorshape'
(what Konsole uses).

*togglecursor_disable_tmux*
*togglecursor_enable_tmux_escaping*

In some versions of tmux, the passthrough handling appears to be slightly
broken. When you are on the last line of a short file, and delete a line with
'dd', tmux appears to insert an extra line into the mix and distorts the
terminal. It appears to be fixed in tmux 1.7. If you'd like to disable using
tmux passthrough support to try and change the cursor, do the following in
your vimrc: >
let g:togglecursor_disable_tmux = 1
The default value for |togglecursor_disable_tmux| is 0.

Note: options should be overridden in your vimrc. Changing them after Vim has
loaded will have little or no effect.
tmux has supported the ability to directly change the cursor for some time now.
If you're using an old version that cannot handle this, then you can enable the
old escaping behavior. This shouldn't be necessary with modern tmux.

*togglecursor_disable_neovim*
Note: This option is no longer supported. Neovim adopted a different mechanism
Expand Down
15 changes: 10 additions & 5 deletions plugin/togglecursor.vim
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ let s:xterm_blinking_block = "\<Esc>[0 q"
let s:xterm_blinking_line = "\<Esc>[5 q"
let s:xterm_blinking_underline = "\<Esc>[3 q"

let s:in_tmux = exists("$TMUX")

" Detect whether this version of vim supports changing the replace cursor
" natively.
let s:sr_supported = exists("+t_SR")
Expand Down Expand Up @@ -119,10 +117,17 @@ if !exists("g:togglecursor_leave")
endif
endif

if !exists("g:togglecursor_disable_tmux")
let g:togglecursor_disable_tmux = 0
if !exists("g:togglecursor_enable_tmux_escaping")
let g:togglecursor_enable_tmux_escaping = 0
endif

if g:togglecursor_enable_tmux_escaping
let s:in_tmux = exists("$TMUX")
else
let s:in_tmux = 0
endif


" -------------------------------------------------------------
" Functions
" -------------------------------------------------------------
Expand All @@ -134,7 +139,7 @@ function! s:TmuxEscape(line)
endfunction

function! s:SupportedTerminal()
if s:supported_terminal == '' || (s:in_tmux && g:togglecursor_disable_tmux)
if s:supported_terminal == ''
return 0
endif

Expand Down

0 comments on commit 4c9ddf6

Please sign in to comment.