Move terminal label register into a contribution

Fixes #136057
This commit is contained in:
Daniel Imms 2021-11-12 14:29:41 -08:00
parent b9777fbaab
commit bf08f79130
3 changed files with 30 additions and 11 deletions

View file

@ -48,6 +48,7 @@ import { TerminalProfileService } from 'vs/workbench/contrib/terminal/browser/te
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { RemoteTerminalBackendContribution } from 'vs/workbench/contrib/terminal/browser/remoteTerminalBackend';
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { TerminalMainContribution } from 'vs/workbench/contrib/terminal/browser/terminalMainContribution';
// Register services
registerSingleton(ITerminalService, TerminalService, true);
@ -73,6 +74,7 @@ CommandsRegistry.registerCommand({ id: quickAccessNavigatePreviousInTerminalPick
// Register workbench contributions
const workbenchRegistry = Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(TerminalMainContribution, LifecyclePhase.Starting);
workbenchRegistry.registerWorkbenchContribution(RemoteTerminalBackendContribution, LifecyclePhase.Starting);
// Register configurations

View file

@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Schemas } from 'vs/base/common/network';
import { ILabelService } from 'vs/platform/label/common/label';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
/**
* The main contribution for the terminal contrib. This contains calls to other components necessary
* to set up the terminal but don't need to be tracked in the long term (where TerminalService would
* be more relevant).
*/
export class TerminalMainContribution implements IWorkbenchContribution {
constructor(
@ILabelService labelService: ILabelService
) {
// Register a resource formatter for terminal URIs
labelService.registerFormatter({
scheme: Schemas.vscodeTerminal,
formatting: {
label: '${path}',
separator: ''
}
});
}
}

View file

@ -17,7 +17,6 @@ import * as nls from 'vs/nls';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ILabelService } from 'vs/platform/label/common/label';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { ICreateContributedTerminalProfileOptions, IShellLaunchConfig, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalLocation, TerminalLocationString } from 'vs/platform/terminal/common/terminal';
import { iconForeground } from 'vs/platform/theme/common/colorRegistry';
@ -138,7 +137,6 @@ export class TerminalService implements ITerminalService {
constructor(
@IContextKeyService private _contextKeyService: IContextKeyService,
@ILabelService labelService: ILabelService,
@ILifecycleService lifecycleService: ILifecycleService,
@IDialogService private _dialogService: IDialogService,
@IInstantiationService private _instantiationService: IInstantiationService,
@ -223,15 +221,6 @@ export class TerminalService implements ITerminalService {
lifecycleService.onBeforeShutdown(async e => e.veto(this._onBeforeShutdown(e.reason), 'veto.terminal'));
lifecycleService.onWillShutdown(e => this._onWillShutdown(e));
// Register a resource formatter for terminal URIs
labelService.registerFormatter({
scheme: Schemas.vscodeTerminal,
formatting: {
label: '${path}',
separator: ''
}
});
// Create async as the class depends on `this`
timeout(0).then(() => this._instantiationService.createInstance(TerminalEditorStyle, document.head));
}