From 541dc0ae0ac59a816c3625f59fae146133e3cb33 Mon Sep 17 00:00:00 2001 From: Andriy Semenets Date: Sun, 2 Dec 2018 18:46:19 +0200 Subject: [PATCH] Display message only once after all jobs are finished. Fix #13 --- plugin/vim-outdated-plugins.vim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugin/vim-outdated-plugins.vim b/plugin/vim-outdated-plugins.vim index d7f8654..0661faf 100644 --- a/plugin/vim-outdated-plugins.vim +++ b/plugin/vim-outdated-plugins.vim @@ -5,10 +5,14 @@ function! s:JobHandler(job_id, data, event) dict endfunction function! s:CalculateUpdates(job_id, data, event) dict - if g:pluginsToUpdate > 0 - echom 'Plugins to update: ' . g:pluginsToUpdate - else - echom 'All plugins up-to-date' + call remove(g:check_for_updates_jobids, a:job_id) + + if len(g:check_for_updates_jobids) == 0 + if g:pluginsToUpdate > 0 + echom 'Plugins to update: ' . g:pluginsToUpdate + else + echom 'All plugins up-to-date' + endif endif endfunction @@ -19,10 +23,11 @@ let s:callbacks = { function! CheckForUpdates() let g:pluginsToUpdate = 0 + let g:check_for_updates_jobids = {} " TODO check only activated plugins and not all downloaded for key in keys(g:plugs) - let job = async#job#start([ 'bash', '-c', "cd " . g:plugs[key].dir ." && git remote update > /dev/null && git rev-list HEAD..origin --count"], s:callbacks) + let g:check_for_updates_jobids[async#job#start([ 'bash', '-c', "cd " . g:plugs[key].dir ." && git remote update > /dev/null && git rev-list HEAD..origin --count"], s:callbacks)] = key endfor endfunction