From 7fe46a23d6bbba02b9093b3759ebd373cf4de9da Mon Sep 17 00:00:00 2001 From: rzvxa Date: Mon, 5 Feb 2024 21:18:04 +0330 Subject: [PATCH] refactor: default argument with variadic arguments. --- lib/nerdtree/creator.vim | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index d3147a9d..9aafb649 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -245,13 +245,18 @@ function! s:Creator.New() endfunction " FUNCTION: s:Creator._nextBufferName(type='') {{{1 -" gets a buffer type of either 'tab' or 'win', defaults to unknown +" gets an optional buffer type of either 'tab' or 'win'. " returns the buffer name for the next nerd tree of such type. -function! s:Creator._nextBufferName(type='') +function! s:Creator._nextBufferName(...) + if a:0 > 0 + let type = a:1 + else + let type = '' + end let name = s:Creator.BufNamePrefix() - if a:type == 'tab' + if type == 'tab' let name = name . 'tab_' - elseif a:type == 'win' + elseif type == 'win' let name = name . 'win_' endif let name = name . self._nextBufferNumber()