mirror of
https://github.com/Microsoft/vscode
synced 2024-11-05 18:29:38 +00:00
Pass process manager through to contributions
This commit is contained in:
parent
b2be676a6b
commit
22d33c40b4
4 changed files with 20 additions and 7 deletions
|
@ -31,7 +31,9 @@ export const ITerminalGroupService = createDecorator<ITerminalGroupService>('ter
|
|||
export const ITerminalInstanceService = createDecorator<ITerminalInstanceService>('terminalInstanceService');
|
||||
|
||||
/**
|
||||
* A terminal contribution that gets created whenever a terminal is created.
|
||||
* A terminal contribution that gets created whenever a terminal is created. A contribution has
|
||||
* access to the process manager through the constructor and provides a method for when xterm.js has
|
||||
* been initialized.
|
||||
*/
|
||||
export interface ITerminalContribution extends IDisposable {
|
||||
xtermReady?(xterm: IXtermTerminal): void;
|
||||
|
|
|
@ -6,15 +6,16 @@
|
|||
import { BrandedService, IConstructorSignature } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ITerminalContribution, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { ITerminalProcessManager } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
|
||||
export type TerminalContributionCtor = IConstructorSignature<ITerminalContribution, [ITerminalInstance]>;
|
||||
export type TerminalContributionCtor = IConstructorSignature<ITerminalContribution, [ITerminalInstance, ITerminalProcessManager]>;
|
||||
|
||||
export interface ITerminalContributionDescription {
|
||||
readonly id: string;
|
||||
readonly ctor: TerminalContributionCtor;
|
||||
}
|
||||
|
||||
export function registerTerminalContribution<Services extends BrandedService[]>(id: string, ctor: { new(editor: ITerminalInstance, ...services: Services): ITerminalContribution }): void {
|
||||
export function registerTerminalContribution<Services extends BrandedService[]>(id: string, ctor: { new(instance: ITerminalInstance, processManager: ITerminalProcessManager, ...services: Services): ITerminalContribution }): void {
|
||||
TerminalContributionRegistry.INSTANCE.registerTerminalContribution(id, ctor);
|
||||
}
|
||||
|
||||
|
@ -37,7 +38,7 @@ class TerminalContributionRegistry {
|
|||
constructor() {
|
||||
}
|
||||
|
||||
public registerTerminalContribution<Services extends BrandedService[]>(id: string, ctor: { new(editor: ITerminalInstance, ...services: Services): ITerminalContribution }): void {
|
||||
public registerTerminalContribution<Services extends BrandedService[]>(id: string, ctor: { new(instance: ITerminalInstance, processManager: ITerminalProcessManager, ...services: Services): ITerminalContribution }): void {
|
||||
this._terminalContributions.push({ id, ctor: ctor as TerminalContributionCtor });
|
||||
}
|
||||
|
||||
|
|
|
@ -586,7 +586,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
const contributionDescs = TerminalExtensionsRegistry.getTerminalContributions();
|
||||
for (const desc of contributionDescs) {
|
||||
try {
|
||||
this._contributions.push(this._scopedInstantiationService.createInstance(desc.ctor, this));
|
||||
this._contributions.push(this._scopedInstantiationService.createInstance(desc.ctor, this, this._processManager));
|
||||
} catch (err) {
|
||||
onUnexpectedError(err);
|
||||
}
|
||||
|
|
|
@ -11,26 +11,36 @@ import { localize } from 'vs/nls';
|
|||
import { registerAction2, Action2 } from 'vs/platform/actions/common/actions';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ITerminalContribution, ITerminalInstance, ITerminalService, IXtermTerminal } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ITerminalProcessManager, TerminalCommandId } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { TerminalContextKeys } from 'vs/workbench/contrib/terminal/common/terminalContextKey';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { terminalStrings } from 'vs/workbench/contrib/terminal/common/terminalStrings';
|
||||
import { DisposableStore, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { registerTerminalContribution } from 'vs/workbench/contrib/terminal/browser/terminalCommon';
|
||||
import { TerminalLinkManager } from 'vs/workbench/contrib/terminal/contrib/links/browser/terminalLinkManager';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
registerSingleton(ITerminalLinkResolverService, TerminalLinkResolverService, InstantiationType.Delayed);
|
||||
|
||||
class TerminalLinkContribution extends DisposableStore implements ITerminalContribution {
|
||||
constructor(instance: ITerminalInstance) {
|
||||
constructor(
|
||||
private readonly _instance: ITerminalInstance,
|
||||
private readonly _processManager: ITerminalProcessManager,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService
|
||||
) {
|
||||
super();
|
||||
console.log('ctor');
|
||||
this.add(toDisposable(() => console.log('dispose')));
|
||||
}
|
||||
xtermReady(xterm: IXtermTerminal): void {
|
||||
console.log('xtermReady');
|
||||
// TODO: Fix cast
|
||||
const linkManager = this._instantiationService.createInstance(TerminalLinkManager, (xterm as any).raw, this._processManager, this._instance.capabilities);
|
||||
console.log('linkManager', linkManager);
|
||||
// TODO: Init terminal link manager here
|
||||
}
|
||||
}
|
||||
// TODO: Use ID to prevent duplicate contributions?
|
||||
registerTerminalContribution('link', TerminalLinkContribution);
|
||||
|
||||
const category = terminalStrings.actionCategory;
|
||||
|
|
Loading…
Reference in a new issue