@@ -61,6 +61,8 @@ define(function (require, exports) {
6161 $tableContainer = $ ( null ) ,
6262 lastCommitMessage = { } ;
6363
64+ let lastVisibleRefreshTime = 0 ;
65+
6466 function lintFile ( filename ) {
6567 var fullPath = Preferences . get ( "currentGitRoot" ) + filename ,
6668 codeInspectionPromise ;
@@ -899,6 +901,9 @@ define(function (require, exports) {
899901 }
900902
901903 function refresh ( ) {
904+ if ( gitPanel && gitPanel . isVisible ( ) ) {
905+ lastVisibleRefreshTime = Date . now ( ) ;
906+ }
902907 // set the history panel to false and remove the class that show the button history active when refresh
903908 $gitPanel . find ( ".git-history-toggle" ) . removeClass ( "active" ) . attr ( "title" , Strings . TOOLTIP_SHOW_HISTORY ) ;
904909 $gitPanel . find ( ".git-file-history" ) . removeClass ( "active" ) . attr ( "title" , Strings . TOOLTIP_SHOW_FILE_HISTORY ) ;
@@ -1611,6 +1616,26 @@ define(function (require, exports) {
16111616 }
16121617 } ) ;
16131618
1619+ const SHOWN_REFRESH_DEDUPE_MS = 500 ;
1620+
1621+ function _refreshOnPanelShown ( ) {
1622+ if ( ! gitPanel || gitPanelDisabled ) {
1623+ return ;
1624+ }
1625+
1626+ // deferred because when the panel is shown via toggle(), the shown event
1627+ // fires from within setVisible() before toggle() calls refresh() itself.
1628+ // by the time this runs, that refresh has stamped lastVisibleRefreshTime
1629+ // and this becomes a no-op instead of a duplicate git status run.
1630+ window . setTimeout ( function ( ) {
1631+ if ( ! gitPanel . isVisible ( ) || Date . now ( ) - lastVisibleRefreshTime < SHOWN_REFRESH_DEDUPE_MS ) {
1632+ return ;
1633+ }
1634+
1635+ EventEmitter . emit ( Events . GIT_PANEL_SHOWN ) ;
1636+ } , 0 ) ;
1637+ }
1638+
16141639 WorkspaceManager . on ( WorkspaceManager . EVENT_WORKSPACE_PANEL_SHOWN , function ( event , panelID ) {
16151640 if ( ! Main . $icon ) {
16161641 return ;
@@ -1619,6 +1644,9 @@ define(function (require, exports) {
16191644 Main . $icon . toggleClass ( "on" , isGitActive ) ;
16201645 Main . $icon . toggleClass ( "selected-button" , isGitActive ) ;
16211646 _setTogglePanelChecked ( isGitActive ) ;
1647+ if ( isGitActive ) {
1648+ _refreshOnPanelShown ( ) ;
1649+ }
16221650 } ) ;
16231651
16241652 exports . init = init ;
0 commit comments