Skip to content

Commit d4968e8

Browse files
authored
Fix potential leak of chat editors (microsoft#223438)
Fixes microsoft#213209 I believe that chat editors are potentially being leaked when progressive rendering ends due to `contentParts` being set without also being disposed of Also fixes the wrong selection potentially being used Fixes microsoft#217835
1 parent 6b1b06d commit d4968e8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/vs/workbench/contrib/chat/browser/chatListRenderer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import { ChatFollowups } from 'vs/workbench/contrib/chat/browser/chatFollowups';
5656
import { ChatMarkdownDecorationsRenderer } from 'vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer';
5757
import { ChatMarkdownRenderer } from 'vs/workbench/contrib/chat/browser/chatMarkdownRenderer';
5858
import { ChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatOptions';
59-
import { ChatCodeBlockContentProvider } from 'vs/workbench/contrib/chat/browser/codeBlockPart';
59+
import { ChatCodeBlockContentProvider, CodeBlockPart } from 'vs/workbench/contrib/chat/browser/codeBlockPart';
6060
import { ChatAgentLocation, IChatAgentMetadata } from 'vs/workbench/contrib/chat/common/chatAgents';
6161
import { CONTEXT_CHAT_RESPONSE_SUPPORT_ISSUE_REPORTING, CONTEXT_REQUEST, CONTEXT_RESPONSE, CONTEXT_RESPONSE_DETECTED_AGENT_COMMAND, CONTEXT_RESPONSE_FILTERED, CONTEXT_RESPONSE_VOTE } from 'vs/workbench/contrib/chat/common/chatContextKeys';
6262
import { IChatRequestVariableEntry, IChatTextEditGroup } from 'vs/workbench/contrib/chat/common/chatModel';
@@ -162,7 +162,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
162162
return ChatListItemRenderer.ID;
163163
}
164164

165-
editorsInUse() {
165+
editorsInUse(): Iterable<CodeBlockPart> {
166166
return this._editorPool.inUse();
167167
}
168168

@@ -488,6 +488,9 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
488488
parts.push(newPart);
489489
}
490490
});
491+
if (templateData.renderedParts) {
492+
dispose(templateData.renderedParts);
493+
}
491494
templateData.renderedParts = parts;
492495

493496
if (isRequestVM(element) && element.variables.length) {

src/vs/workbench/contrib/chat/browser/chatWidget.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
260260
inner.setSelection({
261261
startLineNumber: input.options.selection.startLineNumber,
262262
startColumn: input.options.selection.startColumn,
263-
endLineNumber: input.options.selection.startLineNumber ?? input.options.selection.endLineNumber,
264-
endColumn: input.options.selection.startColumn ?? input.options.selection.endColumn
263+
endLineNumber: input.options.selection.endLineNumber ?? input.options.selection.startLineNumber,
264+
endColumn: input.options.selection.endColumn ?? input.options.selection.startColumn
265265
});
266266
}
267267
return inner;
@@ -413,7 +413,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
413413
`${isResponseVM(element) && element.renderData ? `_${this.visibleChangeCount}` : ''}` +
414414
// Re-render once content references are loaded
415415
(isResponseVM(element) ? `_${element.contentReferences.length}` : '') +
416-
// Rerender request if we got new content references in the response
416+
// Rerender request if we got new content references in the response
417417
// since this may change how we render the corresponding attachments in the request
418418
(isRequestVM(element) && element.contentReferences ? `_${element.contentReferences?.length}` : '');
419419
},

0 commit comments

Comments
 (0)