mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 03:29:00 +01:00
Perform a last minute backup when closing the last window
This commit is contained in:
@@ -193,10 +193,18 @@ export class UntitledEditorModel extends StringEditorModel implements IEncodingS
|
||||
this.fileService.discardBackup(this.resource);
|
||||
}
|
||||
|
||||
private doBackup(): TPromise<void> {
|
||||
public backup(): TPromise<void> {
|
||||
return this.doBackup(true);
|
||||
}
|
||||
|
||||
private doBackup(immediate?: boolean): TPromise<void> {
|
||||
// Cancel any currently running backups to make this the one that succeeds
|
||||
this.cancelBackupPromises();
|
||||
|
||||
if (immediate) {
|
||||
return this.fileService.backupFile(this.resource, this.getValue()).then(f => void 0);
|
||||
}
|
||||
|
||||
// Create new backup promise and keep it
|
||||
const promise = TPromise.timeout(1000).then(() => {
|
||||
this.fileService.backupFile(this.resource, this.getValue()); // Very important here to not return the promise because if the timeout promise is canceled it will bubble up the error otherwise - do not change
|
||||
|
||||
Reference in New Issue
Block a user