Skip to content
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

Dispose some child InstantiationServices #219607

Merged
merged 1 commit into from
Jul 1, 2024
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
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/browser/chatEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class ChatEditor extends EditorPane {

protected override createEditor(parent: HTMLElement): void {
this._scopedContextKeyService = this._register(this.contextKeyService.createScoped(parent));
const scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService]));
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));

this.widget = this._register(
scopedInstantiationService.createInstance(
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/browser/chatInputPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge

const inputScopedContextKeyService = this._register(this.contextKeyService.createScoped(inputContainer));
CONTEXT_IN_CHAT_INPUT.bindTo(inputScopedContextKeyService).set(true);
const scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, inputScopedContextKeyService]));
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, inputScopedContextKeyService])));

const { historyNavigationBackwardsEnablement, historyNavigationForwardsEnablement } = this._register(registerAndCreateHistoryNavigationContext(inputScopedContextKeyService, this));
this.historyNavigationBackwardsEnablement = historyNavigationBackwardsEnablement;
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/chat/browser/chatListRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
const elementDisposables = new DisposableStore();

const contextKeyService = templateDisposables.add(this.contextKeyService.createScoped(rowContainer));
const scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, contextKeyService]));
const scopedInstantiationService = templateDisposables.add(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, contextKeyService])));
let titleToolbar: MenuWorkbenchToolBar | undefined;
if (this.rendererOptions.noHeader) {
header.classList.add('hidden');
Expand Down Expand Up @@ -522,7 +522,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch

element.content.forEach((item, i) => {
if (Array.isArray(item)) {
const scopedInstaService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, templateData.contextKeyService]));
const scopedInstaService = templateData.elementDisposables.add(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, templateData.contextKeyService])));
templateData.elementDisposables.add(
scopedInstaService.createInstance<typeof ChatFollowups<IChatFollowup>, ChatFollowups<IChatFollowup>>(
ChatFollowups,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/browser/chatViewPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class ChatViewPane extends ViewPane {
try {
super.renderBody(parent);

const scopedInstantiationService = this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService]));
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])));
const locationBasedColors = this.getLocationBasedColors();
this._widget = this._register(scopedInstantiationService.createInstance(
ChatWidget,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/chat/browser/chatWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
}

private createList(listContainer: HTMLElement, options: IChatListItemRendererOptions): void {
const scopedInstantiationService = this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService])));
const scopedInstantiationService = this._register(this._register(this.instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService]))));
const delegate = scopedInstantiationService.createInstance(ChatListDelegate, this.viewOptions.defaultElementHeight ?? 200);
const rendererDelegate: IChatRendererDelegate = {
getListLength: () => this.tree.getNode(null).visibleChildrenCount,
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/contrib/chat/browser/codeBlockPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class CodeBlockPart extends Disposable {
this.element = $('.interactive-result-code-block');

this.contextKeyService = this._register(contextKeyService.createScoped(this.element));
const scopedInstantiationService = instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService]));
const scopedInstantiationService = this._register(instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService])));
const editorElement = dom.append(this.element, $('.interactive-result-editor'));
this.editor = this.createEditor(scopedInstantiationService, editorElement, {
...getSimpleEditorOptions(this.configurationService),
Expand Down Expand Up @@ -191,7 +191,7 @@ export class CodeBlockPart extends Disposable {

const toolbarElement = dom.append(this.element, $('.interactive-result-code-block-toolbar'));
const editorScopedService = this.editor.contextKeyService.createScoped(toolbarElement);
const editorScopedInstantiationService = scopedInstantiationService.createChild(new ServiceCollection([IContextKeyService, editorScopedService]));
const editorScopedInstantiationService = this._register(scopedInstantiationService.createChild(new ServiceCollection([IContextKeyService, editorScopedService])));
this.toolbar = this._register(editorScopedInstantiationService.createInstance(MenuWorkbenchToolBar, toolbarElement, menuId, {
menuOptions: {
shouldForwardArgs: true
Expand Down Expand Up @@ -509,7 +509,7 @@ export class CodeCompareBlockPart extends Disposable {
this.messageElement.tabIndex = 0;

this.contextKeyService = this._register(contextKeyService.createScoped(this.element));
const scopedInstantiationService = instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService]));
const scopedInstantiationService = this._register(instantiationService.createChild(new ServiceCollection([IContextKeyService, this.contextKeyService])));
const editorHeader = dom.append(this.element, $('.interactive-result-header.show-file-icons'));
const editorElement = dom.append(this.element, $('.interactive-result-editor'));
this.diffEditor = this.createDiffEditor(scopedInstantiationService, editorElement, {
Expand Down Expand Up @@ -540,7 +540,7 @@ export class CodeCompareBlockPart extends Disposable {
this.resourceLabel = this._register(scopedInstantiationService.createInstance(ResourceLabel, editorHeader, { supportIcons: true }));

const editorScopedService = this.diffEditor.getModifiedEditor().contextKeyService.createScoped(editorHeader);
const editorScopedInstantiationService = scopedInstantiationService.createChild(new ServiceCollection([IContextKeyService, editorScopedService]));
const editorScopedInstantiationService = this._register(scopedInstantiationService.createChild(new ServiceCollection([IContextKeyService, editorScopedService])));
this.toolbar = this._register(editorScopedInstantiationService.createInstance(MenuWorkbenchToolBar, editorHeader, menuId, {
menuOptions: {
shouldForwardArgs: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ suite('PreferencesService', () => {
// PreferencesService creates a PreferencesEditorInput which depends on IPreferencesService, add the real one, not a stub
const collection = new ServiceCollection();
collection.set(IPreferencesService, new SyncDescriptor(PreferencesService));
const instantiationService = testInstantiationService.createChild(collection);
const instantiationService = disposables.add(testInstantiationService.createChild(collection));
testObject = disposables.add(instantiationService.createInstance(PreferencesService));
});
test('options are preserved when calling openEditor', async () => {
Expand Down
Loading