Put worker behind setting

This commit is contained in:
nojaf
2024-08-28 10:59:51 +02:00
parent eb948e1ab7
commit 366df5a69d
3 changed files with 16 additions and 4 deletions

View File

@@ -39,6 +39,12 @@
"scope": "resource",
"markdownDescription": "%ipynb.pasteImagesAsAttachments.enabled%",
"default": true
},
"ipynb.experimental.serialization": {
"type": "boolean",
"scope": "resource",
"markdownDescription": "%ipynb.experimental.serialization%",
"default": false
}
}
}

View File

@@ -2,6 +2,7 @@
"displayName": ".ipynb Support",
"description": "Provides basic support for opening and reading Jupyter's .ipynb notebook files",
"ipynb.pasteImagesAsAttachments.enabled": "Enable/disable pasting of images into Markdown cells in ipynb notebook files. Pasted images are inserted as attachments to the cell.",
"ipynb.experimental.serialization": "Experimental feature to serialize the Jupyter notebook in a worker thread.",
"newUntitledIpynb.title": "New Jupyter Notebook",
"newUntitledIpynb.shortTitle": "Jupyter Notebook",
"openIpynbInNotebookEditor.title": "Open IPYNB File In Notebook Editor",

View File

@@ -107,10 +107,15 @@ export class NotebookSerializer implements vscode.NotebookSerializer {
data.metadata.indentAmount :
' ';
return this.serializeViaWorker({
notebookContent: sorted,
indentAmount
});
const experimentalSave = vscode.workspace.getConfiguration('ipynb').get('experimental.serialization', false);
if (experimentalSave) {
return this.serializeViaWorker({
notebookContent: sorted,
indentAmount
});
} else {
return Promise.resolve(JSON.stringify(sorted, undefined, indentAmount));
}
}
}