@@ -400,12 +400,22 @@ define(function (require, exports) {
400400 }
401401
402402 let isCommandExecuting = false ;
403+ let scheduledRefresh = null ;
404+ const REFRESH_DEDUPE_TIME = 3000 ;
405+
403406 function refreshOnFocusChange ( ) {
404407 // to sync external git changes after switching to app.
405408 if ( gitEnabled ) {
406409 const isGitPanelVisible = Panel . getPanel ( ) . is ( ":visible" ) ;
407410
408411 if ( isCommandExecuting ) {
412+ // if we haven't already scheduled a refresh, queue one
413+ if ( ! scheduledRefresh ) {
414+ scheduledRefresh = setTimeout ( ( ) => {
415+ scheduledRefresh = null ;
416+ refreshOnFocusChange ( ) ;
417+ } , REFRESH_DEDUPE_TIME ) ;
418+ }
409419 return ;
410420 }
411421 isCommandExecuting = true ;
@@ -417,11 +427,24 @@ define(function (require, exports) {
417427 console . error ( "error refreshing on focus switch" , err ) ;
418428 } ) . always ( ( ) => {
419429 isCommandExecuting = false ;
430+ // if a refresh got queued while we were executing, run it immediately now
431+ if ( scheduledRefresh ) {
432+ clearTimeout ( scheduledRefresh ) ;
433+ scheduledRefresh = null ;
434+ refreshOnFocusChange ( ) ;
435+ }
420436 } ) ;
421437 } else {
422438 // if panel not visible, we just refresh the git branch (shown in sidebar)
423439 Branch . refresh ( ) ;
424440 isCommandExecuting = false ;
441+
442+ // run if something got queued
443+ if ( scheduledRefresh ) {
444+ clearTimeout ( scheduledRefresh ) ;
445+ scheduledRefresh = null ;
446+ refreshOnFocusChange ( ) ;
447+ }
425448 }
426449 }
427450 }
0 commit comments