From 3c6dd6d16be1cfb7a4d1244f693e977ab75c6f6d Mon Sep 17 00:00:00 2001 From: Jacobo de Vera Date: Tue, 15 Apr 2014 09:22:15 +0200 Subject: [PATCH] Check name collissions --- autoload/vundle/config.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 1f942e1..561f468 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -7,6 +7,9 @@ " --------------------------------------------------------------------------- func! vundle#config#bundle(arg, ...) let bundle = vundle#config#init_bundle(a:arg, a:000) + if !s:check_bundle_name(bundle) + return + endif if exists('g:vundle_lazy_load') && g:vundle_lazy_load call add(g:bundles, bundle) else @@ -40,6 +43,7 @@ func! vundle#config#init() if !exists('g:bundles') | let g:bundles = [] | endif call s:rtp_rm_a() let g:bundles = [] + let g:bundle_names = {} endf @@ -79,6 +83,26 @@ func! vundle#config#init_bundle(name, opts) endf +" --------------------------------------------------------------------------- +" Check if the current bundle name has already been used in this running +" instance and show an error to that effect. +" +" bundle -- a bundle object whose name is to be checked +" return -- 0 if the bundle's name has been seen before, 1 otherwise +" --------------------------------------------------------------------------- +funct! s:check_bundle_name(bundle) + if has_key(g:bundle_names, a:bundle.name) + echoerr 'Vundle error: Name collision for Plugin ' . a:bundle.name_spec . + \ '. Plugin ' . g:bundle_names[a:bundle.name] . + \ ' previously used the name "' . a:bundle.name . '"' . + \ '. Skipping Plugin ' . a:bundle.name_spec . '.' + return 0 + endif + let g:bundle_names[a:bundle.name] = a:bundle.name_spec + return 1 +endf + + " --------------------------------------------------------------------------- " Parse the options which can be supplied with the bundle specification. " Corresponding documentation: vundle-plugins-configure