Skip to content

Commit aed497c

Browse files
authored
add onTerminal activation event (microsoft#254444)
1 parent 48409cb commit aed497c

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/vs/workbench/contrib/terminal/browser/terminalService.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,18 @@ export class TerminalService extends Disposable implements ITerminalService {
10171017
const location = await this.resolveLocation(options?.location) || this.defaultLocation;
10181018
const parent = await this._getSplitParent(options?.location);
10191019
this._terminalHasBeenCreated.set(true);
1020+
this._extensionService.activateByEvent('onTerminal:*');
1021+
let instance;
10201022
if (parent) {
1021-
return this._splitTerminal(shellLaunchConfig, location, parent);
1023+
instance = this._splitTerminal(shellLaunchConfig, location, parent);
1024+
} else {
1025+
instance = this._createTerminal(shellLaunchConfig, location, options);
10221026
}
1023-
return this._createTerminal(shellLaunchConfig, location, options);
1027+
this._register(instance.onDidChangeShellType(() => this._extensionService.activateByEvent(`onTerminal:${instance.shellType}`)));
1028+
if (instance.shellType) {
1029+
this._extensionService.activateByEvent(`onTerminal:${instance.shellType}`);
1030+
}
1031+
return instance;
10241032
}
10251033

10261034
private async _getContributedProfile(shellLaunchConfig: IShellLaunchConfig, options?: ICreateTerminalOptions): Promise<IExtensionTerminalProfile | undefined> {

src/vs/workbench/services/extensions/common/extensionsRegistry.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,11 @@ export const schema: IJSONSchema = {
398398
body: 'onLanguageModelTool:${1:toolId}',
399399
description: nls.localize('vscode.extension.activationEvents.onLanguageModelTool', 'An activation event emitted when the specified language model tool is invoked.'),
400400
},
401+
{
402+
label: 'onTerminal',
403+
body: 'onTerminal:{1:shellType}',
404+
description: nls.localize('vscode.extension.activationEvents.onTerminal', 'An activation event emitted when a terminal of the given shell type is opened.'),
405+
},
401406
{
402407
label: 'onTerminalCompletionsRequested',
403408
body: 'onTerminalCompletionsRequested',

0 commit comments

Comments
 (0)