diff --git a/README.rst b/README.rst index 2b52358..8dab9b4 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ Vimteractive ============ :vimteractive: send commands from text files to interactive programs via vim :Author: Will Handley -:Version: 2.0.1 +:Version: 2.0.2 :Homepage: https://github.com/williamjameshandley/vimteractive :Documentation: ``:help vimteractive`` diff --git a/autoload/vimteractive.vim b/autoload/vimteractive.vim index dafb049..fed4a85 100644 --- a/autoload/vimteractive.vim +++ b/autoload/vimteractive.vim @@ -168,15 +168,23 @@ endfunction " Connect to vimteractive terminal -function! vimteractive#connect(bufname) +function! vimteractive#connect(...) + " Check that there are buffers to connect to if len(s:vimteractive_buffers) == 0 echoerr "No vimteractive terminal buffers present" echoerr "call :Iterm to start a new one" return endif - let l:bufname = a:bufname - if strlen(a:bufname) ==# 0 + " Check if there was an argument passed to this function + if a:0 == 0 + let l:bufname = '' + else + let l:bufname = a:1 + endif + + " Check if bufname isn't just '' + if l:bufname == '' if len(s:vimteractive_buffers) ==# 1 let l:bufname = vimteractive#buffer_list()[0] else