diff --git a/plugin/vim-tmux-runner.vim b/plugin/vim-tmux-runner.vim index 696fccf..f785a78 100644 --- a/plugin/vim-tmux-runner.vim +++ b/plugin/vim-tmux-runner.vim @@ -304,7 +304,8 @@ function! s:FlushCommand() endif endfunction -function! s:SendCommandToRunner(...) +function! s:SendCommandToRunner(ensure_pane, ...) + if a:ensure_pane | call s:EnsureRunnerPane() | endif if !s:ValidRunnerPaneSet() | return | endif if exists("a:1") && a:1 != "" let s:user_command = shellescape(a:1) @@ -338,7 +339,9 @@ function! s:EnsureRunnerPane(...) endif endfunction -function! s:SendLinesToRunner() range +function! s:SendLinesToRunner(ensure_pane) range + if a:ensure_pane | call s:EnsureRunnerPane() | endif + if !s:ValidRunnerPaneSet() | return | endif call s:SendTextToRunner(getline(a:firstline, a:lastline)) endfunction @@ -370,14 +373,18 @@ function! s:SendCtrlD() call s:SendKeys('') endfunction -function! VtrSendCommand(command) - call s:SendCommandToRunner(a:command) +function! VtrSendCommand(command, ...) + let ensure_pane = 0 + if exists("a:1") + let ensure_pane = a:1 + endif + call s:SendCommandToRunner(ensure_pane, a:command) endfunction function! s:DefineCommands() - command! -nargs=? VtrSendCommandToRunner call s:SendCommandToRunner() command! -nargs=? VtrOpenRunner call s:EnsureRunnerPane() - command! -range VtrSendLinesToRunner ,call s:SendLinesToRunner() + command! -bang -nargs=? VtrSendCommandToRunner call s:SendCommandToRunner(0, ) + command! -bang -range VtrSendLinesToRunner ,call s:SendLinesToRunner(0) command! VtrKillRunner call s:KillRunnerPane() command! VtrFocusRunner call s:FocusRunnerPane() command! VtrReorientRunner call s:ReorientRunner()