Skip to content

Commit 31be502

Browse files
committed
Skip async content part render if disposed of
1 parent db4ac2e commit 31be502

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/vs/workbench/contrib/chat/browser/chatContentParts/chatMarkdownContentPart.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export class ChatMarkdownContentPart extends Disposable implements IChatContentP
7777

7878
private readonly mathLayoutParticipants = new Set<() => void>();
7979

80+
private _isDisposed = false;
81+
8082
constructor(
8183
private readonly markdown: IChatMarkdownContent,
8284
context: IChatContentPartRenderContext,
@@ -110,6 +112,10 @@ export class ChatMarkdownContentPart extends Disposable implements IChatContentP
110112
const enableMath = configurationService.getValue<boolean>(ChatConfiguration.EnableMath);
111113

112114
const doRenderMarkdown = () => {
115+
if (this._isDisposed) {
116+
return;
117+
}
118+
113119
// TODO: Move katex support into chatMarkdownRenderer
114120
const markedExtensions = enableMath
115121
? coalesce([MarkedKatexSupport.getExtension(dom.getWindow(context.container), {
@@ -280,6 +286,11 @@ export class ChatMarkdownContentPart extends Disposable implements IChatContentP
280286
}
281287
}
282288

289+
override dispose(): void {
290+
this._isDisposed = true;
291+
super.dispose();
292+
}
293+
283294
private renderCodeBlockPill(sessionId: string, requestId: string, inUndoStop: string | undefined, codemapperUri: URI | undefined, isStreaming: boolean): IDisposableReference<CollapsedCodeBlock> {
284295
const codeBlock = this.instantiationService.createInstance(CollapsedCodeBlock, sessionId, requestId, inUndoStop);
285296
if (codemapperUri) {

0 commit comments

Comments
 (0)