diff --git a/README.md b/README.md index 328716d..0f5febf 100644 --- a/README.md +++ b/README.md @@ -308,6 +308,26 @@ bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' {} { select-pane -R } ``` +##### A note on the zoomed state + +When wrapping is disabled and in zoomed state, navigation between tmux panes +using `C-h,j,k,l` is not possible using the configuration above, as +`#{pane_at_*}` are all `1` in zoomed state (they reflect the visible window +layout, see `window_layout` vs `window_visible_layout` in `man tmux`). + +One workaround is to replace the conditions `#{pane_at_*}` above with: +``` +#{e|-:#{pane_at_*},#{window_zoomed_flag}} +``` + +This will essentially disable the no-wrapping behavior when zoomed, resulting +in unwrapped navigation (but a working one). + +The same workaround can be enabled for vim using: +```vim +let g:tmux_navigator_no_wrap_disable_when_zoomed = 1 +``` + #### Nesting If you like to nest your tmux sessions, this plugin is not going to work properly. It probably never will, as it would require detecting when Tmux would diff --git a/plugin/tmux_navigator.vim b/plugin/tmux_navigator.vim index abc4fa7..b09922d 100644 --- a/plugin/tmux_navigator.vim +++ b/plugin/tmux_navigator.vim @@ -71,6 +71,10 @@ if !exists("g:tmux_navigator_no_wrap") let g:tmux_navigator_no_wrap = 0 endif +if !exists("g:tmux_navigator_no_wrap_disable_when_zoomed") + let g:tmux_navigator_no_wrap_disable_when_zoomed = 0 +endif + let s:pane_position_from_direction = {'h': 'left', 'j': 'bottom', 'k': 'top', 'l': 'right'} function! s:TmuxOrTmateExecutable() @@ -145,7 +149,11 @@ function! s:TmuxAwareNavigate(direction) let l:args .= ' -Z' endif if g:tmux_navigator_no_wrap == 1 && a:direction != 'p' - let args = 'if -F "#{pane_at_' . s:pane_position_from_direction[a:direction] . '}" "" "' . args . '"' + let condition = '#{pane_at_' . s:pane_position_from_direction[a:direction] . '}' + if g:tmux_navigator_no_wrap_disable_when_zoomed + let condition = '#{e|-:' . condition . ',#{window_zoomed_flag}}' + endif + let args = 'if -F "' . condition . '" "" "' . args . '"' endif silent call s:TmuxCommand(args) if s:NeedsVitalityRedraw()