Skip to content

Commit 2e66ee0

Browse files
authored
listen to other setters for clearing diagnostic (#246791)
listen to other setters
1 parent 248716b commit 2e66ee0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.ts

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { CodeCellViewModel } from '../../viewModel/codeCellViewModel.js';
1515
import { Event } from '../../../../../../base/common/event.js';
1616
import { IChatAgentService } from '../../../../chat/common/chatAgents.js';
1717
import { ChatAgentLocation } from '../../../../chat/common/constants.js';
18+
import { autorun } from '../../../../../../base/common/observable.js';
1819

1920
export class CellDiagnostics extends Disposable implements INotebookEditorContribution {
2021

@@ -121,6 +122,11 @@ export class CellDiagnostics extends Disposable implements INotebookEditorContri
121122
disposables.push(toDisposable(() => this.markerService.changeOne(CellDiagnostics.ID, cell.uri, [])));
122123
cell.executionErrorDiagnostic.set(metadata.error, undefined);
123124
disposables.push(toDisposable(() => cell.executionErrorDiagnostic.set(undefined, undefined)));
125+
disposables.push(autorun((r) => {
126+
if (!cell.executionErrorDiagnostic.read(r)) {
127+
this.clear(cellHandle);
128+
}
129+
}));
124130
disposables.push(cell.model.onDidChangeOutputs(() => {
125131
if (cell.model.outputs.length === 0) {
126132
this.clear(cellHandle);

src/vs/workbench/contrib/notebook/test/browser/contrib/notebookCellDiagnostics.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ suite('notebookCellDiagnostics', () => {
158158
testExecutionService.fireExecutionChanged(editor.textModel.uri, cell2.handle);
159159

160160
await new Promise<void>(resolve => Event.once(markerService.onMarkersUpdated)(resolve));
161-
cell.model.internalMetadata.error = undefined;
162161

162+
const clearMarkers = new Promise<void>(resolve => Event.once(markerService.onMarkersUpdated)(resolve));
163163
// on NotebookCellExecution value will make it look like its currently running
164164
testExecutionService.fireExecutionChanged(editor.textModel.uri, cell.handle, {} as INotebookCellExecution);
165165

166-
await new Promise<void>(resolve => Event.once(markerService.onMarkersUpdated)(resolve));
166+
await clearMarkers;
167167

168168
assert.strictEqual(cell?.executionErrorDiagnostic.get(), undefined);
169169
assert.strictEqual(cell2?.executionErrorDiagnostic.get()?.message, 'another bad thing happened', 'cell that was not executed should still have an error');

0 commit comments

Comments
 (0)