diff --git a/src/polyglot-notebooks-vscode-common/src/commands.ts b/src/polyglot-notebooks-vscode-common/src/commands.ts index a6afdbdb0a..e7b2308012 100644 --- a/src/polyglot-notebooks-vscode-common/src/commands.ts +++ b/src/polyglot-notebooks-vscode-common/src/commands.ts @@ -175,8 +175,8 @@ export function registerFileCommands(context: vscode.ExtensionContext, parserSer const eol = getEol(); const notebookFileFilters = { - 'Polyglot Notebooks': ['dib'], - 'Jupyter Notebooks': ['ipynb'], + 'Polyglot Notebook Script': ['dib'], + 'Jupyter Notebook': ['ipynb'], }; async function newNotebookCommandHandler(preferDefaults: boolean): Promise { diff --git a/src/polyglot-notebooks-vscode-common/src/notebookControllers.ts b/src/polyglot-notebooks-vscode-common/src/notebookControllers.ts index 0d57b93e24..3eb9072282 100644 --- a/src/polyglot-notebooks-vscode-common/src/notebookControllers.ts +++ b/src/polyglot-notebooks-vscode-common/src/notebookControllers.ts @@ -276,13 +276,27 @@ const openedNotebooks = new Set(); function markNotebookAsOpened(notebook: vscode.NotebookDocument) { openedNotebooks.add(notebook.uri.fsPath); } + function isNotebookOpenComplete(notebook: vscode.NotebookDocument) { return openedNotebooks.has(notebook.uri.fsPath); } + function stopTrackingNotebook(notebook: vscode.NotebookDocument) { openedNotebooks.delete(notebook.uri.fsPath); } + async function ensureCellKernelMetadata(cell: vscode.NotebookCell, options: { preferPreviousCellMetadata: boolean }): Promise { + if (cell.document.languageId === 'markdown') { + const existingCellMetadata = cell.metadata?.custom?.metadata; + if (existingCellMetadata?.polyglot_notebook || existingCellMetadata?.dotnet_interactive) { + const updatedCellMetadata = { ...cell.metadata }; + delete updatedCellMetadata.custom.metadata.dotnet_interactive; + delete updatedCellMetadata.custom.metadata.polyglot_notebook; + await vscodeNotebookManagement.replaceNotebookCellMetadata(cell.notebook.uri, cell.index, updatedCellMetadata); + } + return; + } + // if we found the cell ensure it has kernel metadata const cellMetadata = metadataUtilities.getNotebookCellMetadataFromNotebookCellElement(cell); if (!cellMetadata.kernelName) {