@@ -49,7 +49,7 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
49
49
50
50
protected async onFinalBeforeShutdown ( reason : ShutdownReason ) : Promise < boolean > {
51
51
52
- // Important: we are about to shutdown and handle dirty working copies
52
+ // Important: we are about to shutdown and handle modified working copies
53
53
// and backups. We do not want any pending backup ops to interfer with
54
54
// this because there is a risk of a backup being scheduled after we have
55
55
// acknowledged to shutdown and then might end up with partial backups
@@ -67,13 +67,13 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
67
67
68
68
try {
69
69
70
- // Dirty working copies need treatment on shutdown
70
+ // Modified working copies need treatment on shutdown
71
71
const modifiedWorkingCopies = this . workingCopyService . modifiedWorkingCopies ;
72
72
if ( modifiedWorkingCopies . length ) {
73
73
return await this . onBeforeShutdownWithModified ( reason , modifiedWorkingCopies ) ;
74
74
}
75
75
76
- // No dirty working copies
76
+ // No modified working copies
77
77
else {
78
78
return await this . onBeforeShutdownWithoutModified ( ) ;
79
79
}
@@ -85,18 +85,18 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
85
85
protected async onBeforeShutdownWithModified ( reason : ShutdownReason , modifiedWorkingCopies : readonly IWorkingCopy [ ] ) : Promise < boolean > {
86
86
87
87
// If auto save is enabled, save all non-untitled working copies
88
- // and then check again for dirty copies
88
+ // and then check again for modified copies
89
89
90
90
if ( this . filesConfigurationService . getAutoSaveMode ( ) !== AutoSaveMode . OFF ) {
91
91
92
- // Save all dirty working copies
92
+ // Save all modified working copies
93
93
try {
94
94
await this . doSaveAllBeforeShutdown ( false /* not untitled */ , SaveReason . AUTO ) ;
95
95
} catch ( error ) {
96
- this . logService . error ( `[backup tracker] error saving dirty working copies: ${ error } ` ) ; // guard against misbehaving saves, we handle remaining dirty below
96
+ this . logService . error ( `[backup tracker] error saving modified working copies: ${ error } ` ) ; // guard against misbehaving saves, we handle remaining modified below
97
97
}
98
98
99
- // If we still have dirty working copies, we either have untitled ones or working copies that cannot be saved
99
+ // If we still have modified working copies, we either have untitled ones or working copies that cannot be saved
100
100
const remainingModifiedWorkingCopies = this . workingCopyService . modifiedWorkingCopies ;
101
101
if ( remainingModifiedWorkingCopies . length ) {
102
102
return this . handleModifiedBeforeShutdown ( remainingModifiedWorkingCopies , reason ) ;
@@ -129,6 +129,8 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
129
129
}
130
130
}
131
131
132
+ const remainingModifiedWorkingCopies = modifiedWorkingCopies . filter ( workingCopy => ! backups . includes ( workingCopy ) ) ;
133
+
132
134
// We ran a backup but received an error that we show to the user
133
135
if ( backupError ) {
134
136
if ( this . environmentService . isExtensionDevelopment ) {
@@ -137,7 +139,6 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
137
139
return false ; // do not block shutdown during extension development (https://github.com/microsoft/vscode/issues/115028)
138
140
}
139
141
140
- const remainingModifiedWorkingCopies = modifiedWorkingCopies . filter ( workingCopy => ! backups . includes ( workingCopy ) ) ;
141
142
this . showErrorDialog ( localize ( 'backupTrackerBackupFailed' , "The following editors with unsaved changes could not be saved to the back up location." ) , remainingModifiedWorkingCopies , backupError ) ;
142
143
143
144
return true ; // veto (the backup failed)
@@ -146,17 +147,16 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
146
147
// Since a backup did not happen, we have to confirm for
147
148
// the working copies that did not successfully backup
148
149
149
- const remainingDirtyWorkingCopies = modifiedWorkingCopies . filter ( workingCopy => ! backups . includes ( workingCopy ) && workingCopy . isDirty ( ) ) ;
150
150
try {
151
- return await this . confirmBeforeShutdown ( remainingDirtyWorkingCopies ) ;
151
+ return await this . confirmBeforeShutdown ( remainingModifiedWorkingCopies ) ;
152
152
} catch ( error ) {
153
153
if ( this . environmentService . isExtensionDevelopment ) {
154
- this . logService . error ( `[backup tracker] error saving or reverting dirty working copies: ${ error } ` ) ;
154
+ this . logService . error ( `[backup tracker] error saving or reverting modified working copies: ${ error } ` ) ;
155
155
156
156
return false ; // do not block shutdown during extension development (https://github.com/microsoft/vscode/issues/115028)
157
157
}
158
158
159
- this . showErrorDialog ( localize ( 'backupTrackerConfirmFailed' , "The following editors with unsaved changes could not be saved or reverted." ) , remainingDirtyWorkingCopies , error ) ;
159
+ this . showErrorDialog ( localize ( 'backupTrackerConfirmFailed' , "The following editors with unsaved changes could not be saved or reverted." ) , remainingModifiedWorkingCopies , error ) ;
160
160
161
161
return true ; // veto (save or revert failed)
162
162
}
@@ -224,7 +224,7 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
224
224
225
225
await this . withProgressAndCancellation ( async token => {
226
226
227
- // Perform a backup of all dirty working copies unless a backup already exists
227
+ // Perform a backup of all modified working copies unless a backup already exists
228
228
try {
229
229
await Promises . settled ( modifiedWorkingCopies . map ( async workingCopy => {
230
230
@@ -260,46 +260,46 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
260
260
return { backups, error } ;
261
261
}
262
262
263
- private async confirmBeforeShutdown ( dirtyWorkingCopies : IWorkingCopy [ ] ) : Promise < boolean > {
263
+ private async confirmBeforeShutdown ( modifiedWorkingCopies : IWorkingCopy [ ] ) : Promise < boolean > {
264
264
265
265
// Save
266
- const confirm = await this . fileDialogService . showSaveConfirm ( dirtyWorkingCopies . map ( workingCopy => workingCopy . name ) ) ;
266
+ const confirm = await this . fileDialogService . showSaveConfirm ( modifiedWorkingCopies . map ( workingCopy => workingCopy . name ) ) ;
267
267
if ( confirm === ConfirmResult . SAVE ) {
268
- const dirtyCountBeforeSave = this . workingCopyService . dirtyCount ;
268
+ const modifiedCountBeforeSave = this . workingCopyService . modifiedCount ;
269
269
270
270
try {
271
- await this . doSaveAllBeforeShutdown ( dirtyWorkingCopies , SaveReason . EXPLICIT ) ;
271
+ await this . doSaveAllBeforeShutdown ( modifiedWorkingCopies , SaveReason . EXPLICIT ) ;
272
272
} catch ( error ) {
273
- this . logService . error ( `[backup tracker] error saving dirty working copies: ${ error } ` ) ; // guard against misbehaving saves, we handle remaining dirty below
273
+ this . logService . error ( `[backup tracker] error saving modified working copies: ${ error } ` ) ; // guard against misbehaving saves, we handle remaining modified below
274
274
}
275
275
276
- const savedWorkingCopies = dirtyCountBeforeSave - this . workingCopyService . dirtyCount ;
277
- if ( savedWorkingCopies < dirtyWorkingCopies . length ) {
276
+ const savedWorkingCopies = modifiedCountBeforeSave - this . workingCopyService . modifiedCount ;
277
+ if ( savedWorkingCopies < modifiedWorkingCopies . length ) {
278
278
return true ; // veto (save failed or was canceled)
279
279
}
280
280
281
- return this . noVeto ( dirtyWorkingCopies ) ; // no veto (dirty saved)
281
+ return this . noVeto ( modifiedWorkingCopies ) ; // no veto (modified saved)
282
282
}
283
283
284
284
// Don't Save
285
285
else if ( confirm === ConfirmResult . DONT_SAVE ) {
286
286
try {
287
- await this . doRevertAllBeforeShutdown ( dirtyWorkingCopies ) ;
287
+ await this . doRevertAllBeforeShutdown ( modifiedWorkingCopies ) ;
288
288
} catch ( error ) {
289
- this . logService . error ( `[backup tracker] error reverting dirty working copies: ${ error } ` ) ; // do not block the shutdown on errors from revert
289
+ this . logService . error ( `[backup tracker] error reverting modified working copies: ${ error } ` ) ; // do not block the shutdown on errors from revert
290
290
}
291
291
292
- return this . noVeto ( dirtyWorkingCopies ) ; // no veto (dirty reverted)
292
+ return this . noVeto ( modifiedWorkingCopies ) ; // no veto (modified reverted)
293
293
}
294
294
295
295
// Cancel
296
296
return true ; // veto (user canceled)
297
297
}
298
298
299
- private doSaveAllBeforeShutdown ( dirtyWorkingCopies : IWorkingCopy [ ] , reason : SaveReason ) : Promise < void > ;
299
+ private doSaveAllBeforeShutdown ( modifiedWorkingCopies : IWorkingCopy [ ] , reason : SaveReason ) : Promise < void > ;
300
300
private doSaveAllBeforeShutdown ( includeUntitled : boolean , reason : SaveReason ) : Promise < void > ;
301
301
private doSaveAllBeforeShutdown ( arg1 : IWorkingCopy [ ] | boolean , reason : SaveReason ) : Promise < void > {
302
- const dirtyWorkingCopies = Array . isArray ( arg1 ) ? arg1 : this . workingCopyService . dirtyWorkingCopies . filter ( workingCopy => {
302
+ const modifiedWorkingCopies = Array . isArray ( arg1 ) ? arg1 : this . workingCopyService . modifiedWorkingCopies . filter ( workingCopy => {
303
303
if ( arg1 === false && ( workingCopy . capabilities & WorkingCopyCapabilities . Untitled ) ) {
304
304
return false ; // skip untitled unless explicitly included
305
305
}
@@ -313,40 +313,40 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
313
313
const saveOptions = { skipSaveParticipants : true , reason } ;
314
314
315
315
// First save through the editor service if we save all to benefit
316
- // from some extras like switching to untitled dirty editors before saving.
316
+ // from some extras like switching to untitled modified editors before saving.
317
317
318
318
let result : boolean | undefined = undefined ;
319
- if ( typeof arg1 === 'boolean' || dirtyWorkingCopies . length === this . workingCopyService . dirtyCount ) {
319
+ if ( typeof arg1 === 'boolean' || modifiedWorkingCopies . length === this . workingCopyService . modifiedCount ) {
320
320
result = ( await this . editorService . saveAll ( { includeUntitled : typeof arg1 === 'boolean' ? arg1 : true , ...saveOptions } ) ) . success ;
321
321
}
322
322
323
- // If we still have dirty working copies, save those directly
323
+ // If we still have modified working copies, save those directly
324
324
// unless the save was not successful (e.g. cancelled)
325
325
if ( result !== false ) {
326
- await Promises . settled ( dirtyWorkingCopies . map ( workingCopy => workingCopy . isDirty ( ) ? workingCopy . save ( saveOptions ) : Promise . resolve ( true ) ) ) ;
326
+ await Promises . settled ( modifiedWorkingCopies . map ( workingCopy => workingCopy . isModified ( ) ? workingCopy . save ( saveOptions ) : Promise . resolve ( true ) ) ) ;
327
327
}
328
328
} , localize ( 'saveBeforeShutdown' , "Saving editors with unsaved changes is taking a bit longer..." ) ) ;
329
329
}
330
330
331
- private doRevertAllBeforeShutdown ( dirtyWorkingCopies : IWorkingCopy [ ] ) : Promise < void > {
331
+ private doRevertAllBeforeShutdown ( modifiedWorkingCopies : IWorkingCopy [ ] ) : Promise < void > {
332
332
return this . withProgressAndCancellation ( async ( ) => {
333
333
334
334
// Soft revert is good enough on shutdown
335
335
const revertOptions = { soft : true } ;
336
336
337
337
// First revert through the editor service if we revert all
338
- if ( dirtyWorkingCopies . length === this . workingCopyService . dirtyCount ) {
338
+ if ( modifiedWorkingCopies . length === this . workingCopyService . modifiedCount ) {
339
339
await this . editorService . revertAll ( revertOptions ) ;
340
340
}
341
341
342
- // If we still have dirty working copies, revert those directly
343
- await Promises . settled ( dirtyWorkingCopies . map ( workingCopy => workingCopy . isDirty ( ) ? workingCopy . revert ( revertOptions ) : Promise . resolve ( ) ) ) ;
342
+ // If we still have modified working copies, revert those directly
343
+ await Promises . settled ( modifiedWorkingCopies . map ( workingCopy => workingCopy . isModified ( ) ? workingCopy . revert ( revertOptions ) : Promise . resolve ( ) ) ) ;
344
344
} , localize ( 'revertBeforeShutdown' , "Reverting editors with unsaved changes is taking a bit longer..." ) ) ;
345
345
}
346
346
347
347
private onBeforeShutdownWithoutModified ( ) : Promise < boolean > {
348
348
349
- // We are about to shutdown without dirty editors
349
+ // We are about to shutdown without modified editors
350
350
// and will discard any backups that are still
351
351
// around that have not been handled depending
352
352
// on the window state.
@@ -375,7 +375,7 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
375
375
376
376
await this . discardBackupsBeforeShutdown ( arg1 ) ;
377
377
378
- return false ; // no veto (no dirty )
378
+ return false ; // no veto (no modified )
379
379
}
380
380
381
381
private discardBackupsBeforeShutdown ( backupsToDiscard : IWorkingCopyIdentifier [ ] ) : Promise < void > ;
@@ -394,7 +394,7 @@ export class NativeWorkingCopyBackupTracker extends WorkingCopyBackupTracker imp
394
394
395
395
await this . withProgressAndCancellation ( async ( ) => {
396
396
397
- // When we shutdown either with no dirty working copies left
397
+ // When we shutdown either with no modified working copies left
398
398
// or with some handled, we start to discard these backups
399
399
// to free them up. This helps to get rid of stale backups
400
400
// as reported in https://github.com/microsoft/vscode/issues/92962
0 commit comments