-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Change hot exit to create new files for each backup #12377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ export class NativeEditorProvider implements INotebookEditorProvider, CustomEdit | |
context: CustomDocumentOpenContext, // This has info about backups. right now we use our own data. | ||
_cancellation: CancellationToken | ||
): Promise<CustomDocument> { | ||
const model = await this.loadModel(uri, undefined, context.backupId ? false : true); | ||
const model = await this.loadModel(uri, undefined, context.backupId); | ||
return { | ||
uri, | ||
dispose: () => model.dispose() | ||
|
@@ -116,11 +116,11 @@ export class NativeEditorProvider implements INotebookEditorProvider, CustomEdit | |
cancellation: CancellationToken | ||
): Promise<CustomDocumentBackup> { | ||
const model = await this.loadModel(document.uri); | ||
const id = this.storage.getBackupId(model); | ||
this.storage.backup(model, cancellation).ignoreErrors(); | ||
const id = this.storage.generateBackupId(model); | ||
await this.storage.backup(model, cancellation, id); | ||
return { | ||
id, | ||
delete: () => this.storage.deleteBackup(model).ignoreErrors() // This cleans up after save has happened. | ||
delete: () => this.storage.deleteBackup(model, id).ignoreErrors() // This cleans up after save has happened. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete the back associated with this id, hence passing the id. |
||
}; | ||
} | ||
|
||
|
@@ -175,12 +175,16 @@ export class NativeEditorProvider implements INotebookEditorProvider, CustomEdit | |
return this.open(uri); | ||
} | ||
|
||
public async loadModel(file: Uri, contents?: string, skipDirtyContents?: boolean) { | ||
public async loadModel(file: Uri, contents?: string, skipDirtyContents?: boolean): Promise<INotebookModel>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backwards compatibility with old code, hopefully when custom editor is used we can blow away |
||
// tslint:disable-next-line: unified-signatures | ||
public async loadModel(file: Uri, contents?: string, backupId?: string): Promise<INotebookModel>; | ||
// tslint:disable-next-line: no-any | ||
public async loadModel(file: Uri, contents?: string, options?: any): Promise<INotebookModel> { | ||
// Every time we load a new untitled file, up the counter past the max value for this counter | ||
this.untitledCounter = getNextUntitledCounter(file, this.untitledCounter); | ||
|
||
// Load our model from our storage object. | ||
const model = await this.storage.load(file, contents, skipDirtyContents); | ||
const model = await this.storage.load(file, contents, options); | ||
|
||
// Make sure to listen to events on the model | ||
this.trackModel(model); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to wait here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think awaiting here screwed up the custom editor. Can you try it an make sure it still works?