Skip to content

Commit ae8903d

Browse files
authored
Fixes to reverting notebooks (microsoft#12410)
1 parent 2003e01 commit ae8903d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/client/datascience/interactive-ipynb/nativeEditorStorage.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,12 @@ export class NativeEditorStorage implements INotebookStorage {
632632
await this.fileSystem.writeFile(filePath, contents);
633633
}
634634
} else {
635-
await this.fileSystem
636-
.deleteFile(filePath)
637-
.catch((ex) => traceError('Failed to delete hotExit file. Possible it does not exist', ex));
635+
await this.fileSystem.deleteFile(filePath).catch((ex) => {
636+
// No need to log error if file doesn't exist.
637+
if (!isFileNotFoundError(ex)) {
638+
traceError('Failed to delete hotExit file. Possible it does not exist', ex);
639+
}
640+
});
638641
}
639642
}
640643
} catch (exc) {

src/client/datascience/notebook/contentProvider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ export class NotebookContentProvider implements VSCodeNotebookContentProvider {
6565
metadata: { cellEditable: false, editable: false, runnable: false }
6666
};
6767
}
68-
const model = await this.notebookStorage.load(uri, undefined, !openContext.backupId);
68+
// If there's no backup id, then skip loading dirty contents.
69+
const model = await (openContext.backupId
70+
? this.notebookStorage.load(uri, undefined, openContext.backupId)
71+
: this.notebookStorage.load(uri, undefined, true));
6972
// If experiment is not enabled, then this method was invoked as user opted to try and open using the new API.
7073
if (!this.useVSCodeNotebookEditorApi) {
7174
updateModelForUseWithVSCodeNotebook(model);

0 commit comments

Comments
 (0)