chat: fix createModelReference leak in ResolveSymbolsContextAction (#306068)

Improve error handling in ResolveSymbolsContextAction by ensuring model reference disposal
This commit is contained in:
Rob Lourens
2026-03-28 22:15:27 -07:00
committed by GitHub
parent 1ae3819053
commit 83700a8c46

View File

@@ -807,6 +807,7 @@ registerAction2(class ResolveSymbolsContextAction extends EditingSessionAction {
const symbol = args[0] as Location;
const modelReference = await textModelService.createModelReference(symbol.uri);
try {
const textModel = modelReference.object.textEditorModel;
if (!textModel) {
return;
@@ -828,6 +829,9 @@ registerAction2(class ResolveSymbolsContextAction extends EditingSessionAction {
}
chatWidget.attachmentModel.addContext(...attachments);
} finally {
modelReference.dispose();
}
}
private async getReferences(position: Position, textModel: ITextModel, languageFeaturesService: ILanguageFeaturesService): Promise<Location[]> {