Skip to content

Commit 48409cb

Browse files
authored
use onTerminalShellIntegration for terminal suggest activation (microsoft#252329)
1 parent 2f9b4d9 commit 48409cb

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

extensions/terminal-suggest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"main": "./out/terminalSuggestMain",
2727
"activationEvents": [
28-
"onTerminalCompletionsRequested"
28+
"onTerminalShellIntegration:*"
2929
],
3030
"repository": {
3131
"type": "git",

src/vs/workbench/api/browser/mainThreadTerminalShellIntegration.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ITerminalService, type ITerminalInstance } from '../../contrib/terminal
1111
import { IWorkbenchEnvironmentService } from '../../services/environment/common/environmentService.js';
1212
import { extHostNamedCustomer, type IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
1313
import { TerminalShellExecutionCommandLineConfidence } from '../common/extHostTypes.js';
14+
import { IExtensionService } from '../../services/extensions/common/extensions.js';
1415

1516
@extHostNamedCustomer(MainContext.MainThreadTerminalShellIntegration)
1617
export class MainThreadTerminalShellIntegration extends Disposable implements MainThreadTerminalShellIntegrationShape {
@@ -19,7 +20,8 @@ export class MainThreadTerminalShellIntegration extends Disposable implements Ma
1920
constructor(
2021
extHostContext: IExtHostContext,
2122
@ITerminalService private readonly _terminalService: ITerminalService,
22-
@IWorkbenchEnvironmentService workbenchEnvironmentService: IWorkbenchEnvironmentService
23+
@IWorkbenchEnvironmentService workbenchEnvironmentService: IWorkbenchEnvironmentService,
24+
@IExtensionService private readonly _extensionService: IExtensionService
2325
) {
2426
super();
2527

@@ -111,6 +113,11 @@ export class MainThreadTerminalShellIntegration extends Disposable implements Ma
111113
}
112114

113115
private _enableShellIntegration(instance: ITerminalInstance): void {
116+
this._extensionService.activateByEvent('onTerminalShellIntegration:*');
117+
this._register(instance.onDidChangeShellType(() => this._extensionService.activateByEvent(`onTerminalShellIntegration:${instance.shellType}`)));
118+
if (instance.shellType) {
119+
this._extensionService.activateByEvent(`onTerminalShellIntegration:${instance.shellType}`);
120+
}
114121
this._proxy.$shellIntegrationChange(instance.instanceId);
115122
const cwdDetection = instance.capabilities.get(TerminalCapability.CwdDetection);
116123
if (cwdDetection) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ export const schema: IJSONSchema = {
403403
body: 'onTerminalCompletionsRequested',
404404
description: nls.localize('vscode.extension.activationEvents.onTerminalCompletionsRequested', 'An activation event emitted when terminal completions are requested.'),
405405
},
406+
{
407+
label: 'onTerminalShellIntegration',
408+
body: 'onTerminalShellIntegration:${1:shellType}',
409+
description: nls.localize('vscode.extension.activationEvents.onTerminalShellIntegration', 'An activation event emitted when terminal shell integration is activated for the given shell type.'),
410+
},
406411
{
407412
label: 'onMcpCollection',
408413
description: nls.localize('vscode.extension.activationEvents.onMcpCollection', 'An activation event emitted whenver a tool from the MCP server is requested.'),

0 commit comments

Comments
 (0)