Allow multiple calls to VundleChangelog.

The command `silent pedit ...` was causing trouble if the user had `set
hidden`.  Now we `bdelete` the changelog buffer before editing it anew.
This commit is contained in:
Lucas Hoffmann 2014-04-28 12:14:18 +02:00
parent c4d68bcf7c
commit 7d9b10874e

View File

@ -70,6 +70,7 @@ endf
" user. " user.
" --------------------------------------------------------------------------- " ---------------------------------------------------------------------------
func! s:create_changelog() abort func! s:create_changelog() abort
let changelog = ['Updated Plugins:']
for bundle_data in g:updated_bundles for bundle_data in g:updated_bundles
let initial_sha = bundle_data[0] let initial_sha = bundle_data[0]
let updated_sha = bundle_data[1] let updated_sha = bundle_data[1]
@ -83,18 +84,19 @@ func! s:create_changelog() abort
let updates = system(cmd) let updates = system(cmd)
call add(g:vundle_changelog, '') call add(changelog, '')
call add(g:vundle_changelog, 'Updated Plugin: '.bundle.name) call add(changelog, 'Updated Plugin: '.bundle.name)
if bundle.uri =~ "https://github.com" if bundle.uri =~ "https://github.com"
call add(g:vundle_changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha) call add(changelog, 'Compare at: '.bundle.uri[0:-5].'/compare/'.initial_sha.'...'.updated_sha)
endif endif
for update in split(updates, '\n') for update in split(updates, '\n')
let update = substitute(update, '\s\+$', '', '') let update = substitute(update, '\s\+$', '', '')
call add(g:vundle_changelog, ' '.update) call add(changelog, ' '.update)
endfor endfor
endfor endfor
return changelog
endf endf
@ -102,14 +104,15 @@ endf
" View the change log after an update or installation. " View the change log after an update or installation.
" --------------------------------------------------------------------------- " ---------------------------------------------------------------------------
func! s:view_changelog() func! s:view_changelog()
call s:create_changelog() if !exists('s:changelog_file')
let s:changelog_file = tempname()
if !exists('g:vundle_changelog_file')
let g:vundle_changelog_file = tempname()
endif endif
call writefile(g:vundle_changelog, g:vundle_changelog_file) if bufloaded(s:changelog_file)
execute 'silent pedit ' . g:vundle_changelog_file execute 'silent bdelete' s:changelog_file
endif
call writefile(s:create_changelog(), s:changelog_file)
execute 'silent pedit' s:changelog_file
wincmd P | wincmd H wincmd P | wincmd H
endf endf