From 2b29ccfbaa6863231ea74ebb5884c913558d66d6 Mon Sep 17 00:00:00 2001 From: fruzsinaagocs Date: Tue, 10 Sep 2019 14:38:35 +0100 Subject: [PATCH 1/2] Setting default argument for bufname --- autoload/vimteractive.vim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/vimteractive.vim b/autoload/vimteractive.vim index dafb049..af28fdb 100644 --- a/autoload/vimteractive.vim +++ b/autoload/vimteractive.vim @@ -168,15 +168,20 @@ endfunction " Connect to vimteractive terminal -function! vimteractive#connect(bufname) +function! vimteractive#connect(...) + " Check if there was an argument passed to this function + if len(a:000) == 0 + let l:bufname = '' + else + let l:bufname = a:0[0] + endif 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 bufname isn't just '' + if strlen(l:bufname) ==# 0 if len(s:vimteractive_buffers) ==# 1 let l:bufname = vimteractive#buffer_list()[0] else From cc71fbb2ec3979b4ec589e5c18c1b755b9ba8a87 Mon Sep 17 00:00:00 2001 From: Will Handley Date: Tue, 10 Sep 2019 17:55:16 +0100 Subject: [PATCH 2/2] Cleaner logic for processing variable numbers of arguments --- README.rst | 2 +- autoload/vimteractive.vim | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) 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 af28fdb..fed4a85 100644 --- a/autoload/vimteractive.vim +++ b/autoload/vimteractive.vim @@ -169,19 +169,22 @@ endfunction " Connect to vimteractive terminal function! vimteractive#connect(...) - " Check if there was an argument passed to this function - if len(a:000) == 0 - let l:bufname = '' - else - let l:bufname = a:0[0] - endif + " 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 + + " 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 strlen(l:bufname) ==# 0 + if l:bufname == '' if len(s:vimteractive_buffers) ==# 1 let l:bufname = vimteractive#buffer_list()[0] else