Skip to content

Commit

Permalink
Make sure child instantiation service instances are disposed/tracked …
Browse files Browse the repository at this point in the history
…for disposal (#230502)
  • Loading branch information
aeschli authored Oct 4, 2024
1 parent 984db99 commit 02e83d3
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions src/vs/workbench/api/browser/mainThreadCLICommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,34 @@ CommandsRegistry.registerCommand('_remoteCLI.manageExtensions', async function (
lines.push(message);
}
}();
const cliService = instantiationService.createChild(new ServiceCollection([IExtensionManagementService, remoteExtensionManagementService])).createInstance(RemoteExtensionManagementCLI, logger);

if (args.list) {
await cliService.listExtensions(!!args.list.showVersions, args.list.category, undefined);
} else {
const revive = (inputs: (string | UriComponents)[]) => inputs.map(input => isString(input) ? input : URI.revive(input));
if (Array.isArray(args.install) && args.install.length) {
try {
await cliService.installExtensions(revive(args.install), [], { isMachineScoped: true }, !!args.force);
} catch (e) {
lines.push(e.message);
const childInstantiationService = instantiationService.createChild(new ServiceCollection([IExtensionManagementService, remoteExtensionManagementService]));
try {
const cliService = childInstantiationService.createInstance(RemoteExtensionManagementCLI, logger);

if (args.list) {
await cliService.listExtensions(!!args.list.showVersions, args.list.category, undefined);
} else {
const revive = (inputs: (string | UriComponents)[]) => inputs.map(input => isString(input) ? input : URI.revive(input));
if (Array.isArray(args.install) && args.install.length) {
try {
await cliService.installExtensions(revive(args.install), [], { isMachineScoped: true }, !!args.force);
} catch (e) {
lines.push(e.message);
}
}
}
if (Array.isArray(args.uninstall) && args.uninstall.length) {
try {
await cliService.uninstallExtensions(revive(args.uninstall), !!args.force, undefined);
} catch (e) {
lines.push(e.message);
if (Array.isArray(args.uninstall) && args.uninstall.length) {
try {
await cliService.uninstallExtensions(revive(args.uninstall), !!args.force, undefined);
} catch (e) {
lines.push(e.message);
}
}
}
return lines.join('\n');
} finally {
childInstantiationService.dispose();
}
return lines.join('\n');

});

class RemoteExtensionManagementCLI extends ExtensionManagementCLI {
Expand Down

0 comments on commit 02e83d3

Please sign in to comment.