Skip to content

Commit

Permalink
Prevent zooming out of tmux pane
Browse files Browse the repository at this point in the history
There were issues (e.g. christoomey#56) and pull requests (christoomey#65 and christoomey#104) to improve this
behavior, but they were mainly rejected because it breaks other use cases.

This PR adds an option that can be enabled to have the current behavior
(`let g:tmux_navigator_move_out_of_zoomed_tmux = 1`) by default, but it also
recognizes when the user tries to get out of the zoomed pane twice, and
then allows for it.
  • Loading branch information
blueyed committed Feb 4, 2017
1 parent 34f8fbf commit 315848d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions plugin/tmux_navigator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ function! s:TmuxAwareNavigate(direction)
endtry
endif
let args = 'select-pane -t ' . shellescape($TMUX_PANE) . ' -' . tr(a:direction, 'phjkl', 'lLDUR')

" Handle delay for moving out of zoomed tmux pane.
" This wraps the tmux args conditionally.
let timeout = get(g:, 'tmux_navigator_zoomed_tmux_delay', 0.5)
if timeout != 0
let msg = 'Tmux is zoomed, not moving out.'
let curtime = reltimefloat(reltime())
if (a:direction != s:tried_moving_out_of_zoomed_tmux[0]
\ || curtime > (s:tried_moving_out_of_zoomed_tmux[1] + timeout))
" 0 to zoom out always
" -1 can be used to never zoom out.
let msg .= printf(' Trigger it again in %.1f seconds to zoom out.',
\ timeout)
let msg .= ' See the help for g:tmux_navigator_zoomed_tmux_delay.'
let s:tried_moving_out_of_zoomed_tmux = [a:direction, curtime]
let args = "if -F '#{window_zoomed_flag}' 'display \"".msg."\"'"
\ ." '".args."'"
else
let s:tried_moving_out_of_zoomed_tmux = ['', 0]
endif
endif
silent call s:TmuxCommand(args)
if s:NeedsVitalityRedraw()
redraw!
Expand All @@ -88,6 +109,7 @@ function! s:TmuxAwareNavigate(direction)
let s:tmux_is_last_pane = 0
endif
endfunction
let s:tried_moving_out_of_zoomed_tmux = ['', 0]

function! s:VimNavigate(direction)
try
Expand Down

0 comments on commit 315848d

Please sign in to comment.