From f39a860595ae5b7f296839e9ceaadf44823c99f8 Mon Sep 17 00:00:00 2001 From: Chris Toomey Date: Wed, 31 Dec 2014 11:25:22 -0500 Subject: [PATCH] Capture the major orientation with AttachToPane ReorientRunner needs to know the current orientation in order to be able to toggle it. With this change, we capture the current major orientation (outermost split orientation) and assume it to be representative. Imperfect, but I believe it to be a very good approximation. Closes #32 - Error: Reorient Runner fails when run after manual attach --- plugin/vim-tmux-runner.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugin/vim-tmux-runner.vim b/plugin/vim-tmux-runner.vim index e97e746..dcc4b5a 100644 --- a/plugin/vim-tmux-runner.vim +++ b/plugin/vim-tmux-runner.vim @@ -253,9 +253,18 @@ function! s:PromptForRunnerToAttach() endif endfunction +function! s:CurrentMajorOrientation() + let orientation_map = { '[': 'v', '{': 'h' } + let layout = s:TmuxInfo('window_layout') + let outermost_orientation = substitute(layout, '[^[{]', '', 'g')[0] + return orientation_map[outermost_orientation] +endfunction + function! s:AttachToPane(desired_pane) if s:ValidRunnerPaneNumber(a:desired_pane) let s:runner_pane = a:desired_pane + let s:vim_pane = s:ActivePaneIndex() + let s:vtr_orientation = s:CurrentMajorOrientation() echohl String | echo "\rRunner pane set to: " . a:desired_pane | echohl None else call s:EchoError("Invalid pane number: " . a:desired_pane)