mirror of
https://github.com/Microsoft/vscode
synced 2024-11-05 18:29:38 +00:00
Avoid blocking event loop when saving nb (#207381)
This commit is contained in:
parent
30f1a7103b
commit
7696df9026
1 changed files with 21 additions and 26 deletions
|
@ -81,36 +81,31 @@ export class AttachmentCleaner implements vscode.CodeActionProvider {
|
|||
this._disposables.push(vscode.workspace.onWillSaveNotebookDocument(e => {
|
||||
if (e.reason === vscode.TextDocumentSaveReason.Manual) {
|
||||
this._delayer.dispose();
|
||||
|
||||
e.waitUntil(new Promise((resolve) => {
|
||||
if (e.notebook.getCells().length === 0) {
|
||||
return;
|
||||
if (e.notebook.getCells().length === 0) {
|
||||
return;
|
||||
}
|
||||
const notebookEdits: vscode.NotebookEdit[] = [];
|
||||
for (const cell of e.notebook.getCells()) {
|
||||
if (cell.kind !== vscode.NotebookCellKind.Markup) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const notebookEdits: vscode.NotebookEdit[] = [];
|
||||
for (const cell of e.notebook.getCells()) {
|
||||
if (cell.kind !== vscode.NotebookCellKind.Markup) {
|
||||
continue;
|
||||
}
|
||||
const metadataEdit = this.cleanNotebookAttachments({
|
||||
notebook: e.notebook,
|
||||
cell: cell,
|
||||
document: cell.document
|
||||
});
|
||||
|
||||
const metadataEdit = this.cleanNotebookAttachments({
|
||||
notebook: e.notebook,
|
||||
cell: cell,
|
||||
document: cell.document
|
||||
});
|
||||
|
||||
if (metadataEdit) {
|
||||
notebookEdits.push(metadataEdit);
|
||||
}
|
||||
if (metadataEdit) {
|
||||
notebookEdits.push(metadataEdit);
|
||||
}
|
||||
if (!notebookEdits.length) {
|
||||
return;
|
||||
}
|
||||
const workspaceEdit = new vscode.WorkspaceEdit();
|
||||
workspaceEdit.set(e.notebook.uri, notebookEdits);
|
||||
|
||||
resolve(workspaceEdit);
|
||||
}));
|
||||
}
|
||||
if (!notebookEdits.length) {
|
||||
return;
|
||||
}
|
||||
const workspaceEdit = new vscode.WorkspaceEdit();
|
||||
workspaceEdit.set(e.notebook.uri, notebookEdits);
|
||||
e.waitUntil(Promise.resolve(workspaceEdit));
|
||||
}
|
||||
}));
|
||||
|
||||
|
|
Loading…
Reference in a new issue