Skip to content

listen to other setters for clearing diagnostic #246791

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

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CodeCellViewModel } from '../../viewModel/codeCellViewModel.js';
import { Event } from '../../../../../../base/common/event.js';
import { IChatAgentService } from '../../../../chat/common/chatAgents.js';
import { ChatAgentLocation } from '../../../../chat/common/constants.js';
import { autorun } from '../../../../../../base/common/observable.js';

export class CellDiagnostics extends Disposable implements INotebookEditorContribution {

Expand Down Expand Up @@ -121,6 +122,11 @@ export class CellDiagnostics extends Disposable implements INotebookEditorContri
disposables.push(toDisposable(() => this.markerService.changeOne(CellDiagnostics.ID, cell.uri, [])));
cell.executionErrorDiagnostic.set(metadata.error, undefined);
disposables.push(toDisposable(() => cell.executionErrorDiagnostic.set(undefined, undefined)));
disposables.push(autorun((r) => {
if (!cell.executionErrorDiagnostic.read(r)) {
this.clear(cellHandle);
}
}));
disposables.push(cell.model.onDidChangeOutputs(() => {
if (cell.model.outputs.length === 0) {
this.clear(cellHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ suite('notebookCellDiagnostics', () => {
testExecutionService.fireExecutionChanged(editor.textModel.uri, cell2.handle);

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

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

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

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