-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Better handling of notebook diagnostics #16529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Clear Notebook Cell diagnostics when deleting a cell or closing a notebook. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,8 @@ export class NotebookConverter implements Disposable { | |
|
|
||
| private onDidChangeCellsEmitter = new EventEmitter<TextDocumentChangeEvent>(); | ||
|
|
||
| private mapOfConcatDocumentsWithCellUris = new Map<string, string[]>(); | ||
|
|
||
| constructor( | ||
| private api: IVSCodeNotebook, | ||
| private fs: IFileSystem, | ||
|
|
@@ -127,9 +129,18 @@ export class NotebookConverter implements Disposable { | |
| if (wrapper) { | ||
| // Diagnostics are supposed to be per file and are updated each time | ||
| // Make sure to clear out old ones first | ||
| const cellUris: string[] = []; | ||
| const oldCellUris = this.mapOfConcatDocumentsWithCellUris.get(uri.toString()) || []; | ||
| wrapper.notebook.getCells().forEach((c: NotebookCell) => { | ||
| result.set(c.document.uri, []); | ||
| cellUris.push(c.document.uri.toString()); | ||
| }); | ||
| // Possible some cells were deleted, we need to clear the diagnostics of those cells as well. | ||
| const currentCellUris = new Set(cellUris); | ||
| oldCellUris | ||
| .filter((cellUri) => !currentCellUris.has(cellUri)) | ||
| .forEach((cellUri) => result.set(Uri.parse(cellUri), [])); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, if we delete a cell, the diagnostics of deleted cells remains & doesn't go away. |
||
| this.mapOfConcatDocumentsWithCellUris.set(uri.toString(), cellUris); | ||
|
|
||
| // Then for all the new ones, set their values. | ||
| diagnostics.forEach((d) => { | ||
|
|
@@ -141,6 +152,11 @@ export class NotebookConverter implements Disposable { | |
| } | ||
| list.push(this.toIncomingDiagnostic(location.uri, d)); | ||
| }); | ||
| } else if (this.mapOfConcatDocumentsWithCellUris.has(uri.toString())) { | ||
| (this.mapOfConcatDocumentsWithCellUris.get(uri.toString()) || []) | ||
| .map((cellUri) => Uri.parse(cellUri)) | ||
| .forEach((cellUri) => result.set(cellUri, [])); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, if a notebook is closed, the diagnostics don't go away. |
||
| this.mapOfConcatDocumentsWithCellUris.delete(uri.toString()); | ||
| } else { | ||
| result.set(uri, diagnostics); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storing the Uris as strings (don't want to be storing the objects)