File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,8 @@ class FileList {
2929
3030 this . buckets = new Map ( )
3131
32- this . _refreshing = Promise . resolve ( )
32+ // A promise that is pending if and only if we are active in this.refresh_()
33+ this . _refreshing = null
3334
3435 const emit = ( ) => {
3536 this . _emitter . emit ( 'file_list_modified' , this . files )
@@ -65,8 +66,8 @@ class FileList {
6566 _refresh ( ) {
6667 const matchedFiles = new Set ( )
6768
68- let promise
69- promise = Promise . map ( this . _patterns , ( patternObject ) => {
69+ let lastCompletedRefresh = this . _refreshing
70+ lastCompletedRefresh = Promise . map ( this . _patterns , ( patternObject ) => {
7071 const pattern = patternObject . pattern
7172 const type = patternObject . type
7273
@@ -113,14 +114,18 @@ class FileList {
113114 } )
114115 } )
115116 . then ( ( ) => {
116- if ( this . _refreshing !== promise ) {
117+ // When we return from this function the file processing chain will be
118+ // complete. In the case of two fast refresh() calls, the second call
119+ // will overwrite this._refreshing, and we want the status to reflect
120+ // the second call and skip the modification event from the first call.
121+ if ( this . _refreshing !== lastCompletedRefresh ) {
117122 return this . _refreshing
118123 }
119124 this . _emitModified ( true )
120125 return this . files
121126 } )
122127
123- return promise
128+ return lastCompletedRefresh
124129 }
125130
126131 get files ( ) {
You can’t perform that action at this time.
0 commit comments