@@ -53,17 +53,11 @@ export class GitExtension implements IGitExtension {
5353 // Initialize repository status
5454 this . _clearStatus ( ) ;
5555
56- let interval : number ;
57- if ( settings ) {
58- interval = settings . composite . refreshInterval as number ;
59- settings . changed . connect ( this . _onSettingsChange , this ) ;
60- } else {
61- interval = DEFAULT_REFRESH_INTERVAL ;
62- }
56+ const interval = DEFAULT_REFRESH_INTERVAL ;
6357 this . _statusPoll = new Poll ( {
6458 factory : this . _refreshModel ,
6559 frequency : {
66- interval : interval ,
60+ interval,
6761 backoff : true ,
6862 max : 300 * 1000
6963 } ,
@@ -79,6 +73,11 @@ export class GitExtension implements IGitExtension {
7973 } ,
8074 standby : this . _refreshStandby
8175 } ) ;
76+
77+ if ( settings ) {
78+ settings . changed . connect ( this . _onSettingsChange , this ) ;
79+ this . _onSettingsChange ( settings ) ;
80+ }
8281 }
8382
8483 /**
@@ -269,23 +268,17 @@ export class GitExtension implements IGitExtension {
269268 }
270269
271270 /**
272- * Boolean indicating whether there are dirty staged files
273- * (e.g., due to unsaved changes on files that have been previously staged).
271+ * Boolean indicating whether there are dirty files
272+ * A dirty file is a file with unsaved changes that is staged in classical mode
273+ * or modified in simple mode.
274274 */
275- get hasDirtyStagedFiles ( ) : boolean {
276- return this . _hasDirtyStagedFiles ;
275+ get hasDirtyFiles ( ) : boolean {
276+ return this . _hasDirtyFiles ;
277277 }
278- /**
279- * Updates the value of the boolean indicating whether there are dirty staged files
280- * (e.g., due to unsaved changes on files that have been previously staged).
281- * Emits a signal indicating if necessary.
282- * This signal is emitted when there is a dirty staged file but none previously,
283- * and vice versa, when there are no dirty staged files but there were some previously.
284- */
285- set hasDirtyStagedFiles ( value : boolean ) {
286- if ( this . _hasDirtyStagedFiles !== value ) {
287- this . _hasDirtyStagedFiles = value ;
288- this . _dirtyStagedFilesStatusChanged . emit ( value ) ;
278+ set hasDirtyFiles ( value : boolean ) {
279+ if ( this . _hasDirtyFiles !== value ) {
280+ this . _hasDirtyFiles = value ;
281+ this . _dirtyFilesStatusChanged . emit ( value ) ;
289282 }
290283 }
291284
@@ -294,8 +287,8 @@ export class GitExtension implements IGitExtension {
294287 * This signal is emitted when there is a dirty staged file but none previously,
295288 * and vice versa, when there are no dirty staged files but there were some previously.
296289 */
297- get dirtyStagedFilesStatusChanged ( ) : ISignal < IGitExtension , boolean > {
298- return this . _dirtyStagedFilesStatusChanged ;
290+ get dirtyFilesStatusChanged ( ) : ISignal < IGitExtension , boolean > {
291+ return this . _dirtyFilesStatusChanged ;
299292 }
300293
301294 /**
@@ -1090,7 +1083,7 @@ export class GitExtension implements IGitExtension {
10901083 behind : data . behind || 0 ,
10911084 files
10921085 } ) ;
1093- await this . refreshDirtyStagedStatus ( ) ;
1086+ await this . refreshDirtyStatus ( ) ;
10941087 } catch ( err ) {
10951088 // TODO we should notify the user
10961089 this . _clearStatus ( ) ;
@@ -1179,19 +1172,18 @@ export class GitExtension implements IGitExtension {
11791172 }
11801173
11811174 /**
1182- * Determines whether there are unsaved changes on staged files,
1183- * e.g., the user has made changes to a file that has been staged,
1184- * but has not saved them.
1185- * @returns promise that resolves upon refreshing the dirty status of staged files
1175+ * Determines whether there are unsaved changes on files,
1176+ *
1177+ * @returns promise that resolves upon refreshing the dirty status of files
11861178 */
1187- async refreshDirtyStagedStatus ( ) : Promise < void > {
1179+ async refreshDirtyStatus ( ) : Promise < void > {
11881180 // we assume the repository status has been refreshed prior to this
11891181
1190- // get staged files
1191- const stagedFiles = this . status . files . filter (
1192- file => file . status === 'staged' || file . status === 'partially-staged'
1182+ // get files
1183+ const files = this . status . files . filter ( file =>
1184+ this . _statusForDirtyState . includes ( file . status )
11931185 ) ;
1194- const fileNames = stagedFiles . map ( file => file . to ) ;
1186+ const fileNames = files . map ( file => file . to ) ;
11951187
11961188 let result = false ;
11971189
@@ -1208,7 +1200,7 @@ export class GitExtension implements IGitExtension {
12081200 }
12091201 }
12101202
1211- this . hasDirtyStagedFiles = result ;
1203+ this . hasDirtyFiles = result ;
12121204 }
12131205
12141206 /**
@@ -1631,6 +1623,11 @@ export class GitExtension implements IGitExtension {
16311623 ...this . _statusPoll . frequency ,
16321624 interval : settings . composite . refreshInterval as number
16331625 } ;
1626+
1627+ this . _statusForDirtyState = ( settings . composite . simpleStaging as boolean )
1628+ ? [ 'staged' , 'partially-staged' , 'unstaged' ]
1629+ : [ 'staged' , 'partially-staged' ] ;
1630+ this . refreshDirtyStatus ( ) ;
16341631 }
16351632
16361633 /**
@@ -1721,9 +1718,12 @@ export class GitExtension implements IGitExtension {
17211718 private _remoteChangedFiles : Git . IStatusFile [ ] = [ ] ;
17221719 private _changeUpstreamNotified : Git . IStatusFile [ ] = [ ] ;
17231720 private _selectedHistoryFile : Git . IStatusFile | null = null ;
1724- private _hasDirtyStagedFiles = false ;
1721+ private _hasDirtyFiles = false ;
17251722 private _credentialsRequired = false ;
17261723
1724+ // Configurable
1725+ private _statusForDirtyState : Git . Status [ ] = [ 'staged' , 'partially-staged' ] ;
1726+
17271727 private _branchesChanged = new Signal < IGitExtension , void > ( this ) ;
17281728 private _headChanged = new Signal < IGitExtension , void > ( this ) ;
17291729 private _markChanged = new Signal < IGitExtension , void > ( this ) ;
@@ -1740,9 +1740,7 @@ export class GitExtension implements IGitExtension {
17401740 IGitExtension ,
17411741 Git . IRemoteChangedNotification | null
17421742 > ( this ) ;
1743- private _dirtyStagedFilesStatusChanged = new Signal < IGitExtension , boolean > (
1744- this
1745- ) ;
1743+ private _dirtyFilesStatusChanged = new Signal < IGitExtension , boolean > ( this ) ;
17461744 private _credentialsRequiredChanged = new Signal < IGitExtension , boolean > (
17471745 this
17481746 ) ;
0 commit comments