Notebook Views initialization fix (#17109)

Separate the Views load from the initialization. This way we can load previously created views, and only add the new views data to the document when needed. For now, this happens only when a view is created.
This commit is contained in:
Daniel Grajeda
2021-10-22 15:50:21 -06:00
committed by GitHub
parent 6e65063317
commit 6200a61382
6 changed files with 80 additions and 33 deletions

View File

@@ -208,7 +208,7 @@ suite('NotebookViewModel', function (): void {
viewModel.initialize();
let cell = viewModel.cells[0];
let cellMeta = notebookViews.getCellMetadata(cell);
let cellMeta = notebookViews.getExtensionCellMetadata(cell);
assert(!isUndefinedOrNull(cellMeta.views.find(v => v.guid === viewModel.guid)));
assert.deepStrictEqual(viewModel.getCellMetadata(cell), cellMeta.views.find(v => v.guid === viewModel.guid));

View File

@@ -76,6 +76,19 @@ suite('NotebookViews', function (): void {
notebookViews = await initializeExtension();
});
test('should not modify the notebook document until a view is created', async () => {
//Create some content
notebookViews.notebook.addCell(CellTypes.Code, 0);
const cell = notebookViews.notebook.cells[0];
assert.strictEqual(notebookViews.getExtensionMetadata(), undefined);
assert.strictEqual(notebookViews.getExtensionCellMetadata(cell), undefined);
//Check that the view is created
notebookViews.createNewView(defaultViewName);
assert.notStrictEqual(notebookViews.getExtensionMetadata(), undefined);
});
test('create new view', async function (): Promise<void> {
assert.strictEqual(notebookViews.getViews().length, 0, 'notebook should not initially generate any views');