mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-28 05:14:12 +08:00
fix: memory leak in notebook attachment diagnostics (#333383)
* fix: dispose notebook attachment diagnostics * fix: preserve diagnostics when moving notebook cells --------- Co-authored-by: Dmitriy Vasyura <dmitriv@microsoft.com>
This commit is contained in:
co-authored by
Dmitriy Vasyura
parent
265cdf226b
commit
b995b9ffd0
@@ -52,6 +52,14 @@ export class AttachmentCleaner implements vscode.CodeActionProvider {
|
||||
}));
|
||||
|
||||
this._disposables.push(vscode.workspace.onDidChangeNotebookDocument(e => {
|
||||
for (const change of e.contentChanges) {
|
||||
for (const cell of change.removedCells) {
|
||||
if (cell.document.isClosed) {
|
||||
this._imageDiagnosticCollection.delete(cell.document.uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._delayer.trigger(() => {
|
||||
|
||||
e.cellChanges.forEach(change => {
|
||||
@@ -111,6 +119,9 @@ export class AttachmentCleaner implements vscode.CodeActionProvider {
|
||||
|
||||
this._disposables.push(vscode.workspace.onDidCloseNotebookDocument(e => {
|
||||
this._attachmentCache.delete(e.uri.toString());
|
||||
for (const cell of e.getCells()) {
|
||||
this._imageDiagnosticCollection.delete(cell.document.uri);
|
||||
}
|
||||
}));
|
||||
|
||||
this._disposables.push(vscode.workspace.onWillRenameFiles(e => {
|
||||
@@ -133,7 +144,7 @@ export class AttachmentCleaner implements vscode.CodeActionProvider {
|
||||
}));
|
||||
|
||||
this._disposables.push(vscode.workspace.onDidCloseTextDocument(e => {
|
||||
this.analyzeMissingAttachments(e);
|
||||
this._imageDiagnosticCollection.delete(e.uri);
|
||||
}));
|
||||
|
||||
vscode.workspace.textDocuments.forEach(document => {
|
||||
@@ -246,7 +257,7 @@ export class AttachmentCleaner implements vscode.CodeActionProvider {
|
||||
}
|
||||
|
||||
if (document.isClosed) {
|
||||
this.updateDiagnostics(document.uri, []);
|
||||
this._imageDiagnosticCollection.delete(document.uri);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -388,4 +399,3 @@ export class AttachmentCleaner implements vscode.CodeActionProvider {
|
||||
this._delayer.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user