Skip to content

Commit

Permalink
Try use shell integration in debug terminals
Browse files Browse the repository at this point in the history
Fixes #204694
  • Loading branch information
Tyriar committed Feb 12, 2024
1 parent 66713a4 commit 5451a4e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/vs/platform/terminal/common/terminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,12 @@ export interface IShellLaunchConfig {
*/
isTransient?: boolean;

/**
* Attempt to force shell integration to be enabled by bypassing the {@link isFeatureTerminal}
* equals false requirement.
*/
forceShellIntegration?: boolean;

/**
* Create a terminal without shell integration even when it's enabled
*/
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/terminal/node/terminalEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function getShellIntegrationInjection(
// - There is no executable (not sure what script to run)
// - The terminal is used by a feature like tasks or debugging
const useWinpty = isWindows && (!options.windowsEnableConpty || getWindowsBuildNumber() < 18309);
if (!options.shellIntegration.enabled || !shellLaunchConfig.executable || shellLaunchConfig.isFeatureTerminal || shellLaunchConfig.hideFromUser || shellLaunchConfig.ignoreShellIntegration || useWinpty) {
if (!options.shellIntegration.enabled || !shellLaunchConfig.executable || (shellLaunchConfig.isFeatureTerminal && !shellLaunchConfig.forceShellIntegration) || shellLaunchConfig.hideFromUser || shellLaunchConfig.ignoreShellIntegration || useWinpty) {
return undefined;
}

Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/browser/mainThreadTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class MainThreadTerminalService implements MainThreadTerminalServiceShape
? (id, cols, rows) => new TerminalProcessExtHostProxy(id, cols, rows, this._terminalService)
: undefined,
extHostTerminalId,
forceShellIntegration: launchConfig.forceShellIntegration,
isFeatureTerminal: launchConfig.isFeatureTerminal,
isExtensionOwnedTerminal: launchConfig.isExtensionOwnedTerminal,
useShellEnvironment: launchConfig.useShellEnvironment,
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ export interface TerminalLaunchConfig {
strictEnv?: boolean;
hideFromUser?: boolean;
isExtensionCustomPtyTerminal?: boolean;
forceShellIntegration?: boolean;
isFeatureTerminal?: boolean;
isExtensionOwnedTerminal?: boolean;
useShellEnvironment?: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/api/common/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ interface IEnvironmentVariableCollection extends vscode.EnvironmentVariableColle
export interface ITerminalInternalOptions {
cwd?: string | URI;
isFeatureTerminal?: boolean;
forceShellIntegration?: boolean;
useShellEnvironment?: boolean;
resolvedExtHostIdentifier?: ExtHostTerminalIdentifier;
/**
Expand Down Expand Up @@ -165,6 +166,7 @@ export class ExtHostTerminal {
initialText: options.message ?? undefined,
strictEnv: options.strictEnv ?? undefined,
hideFromUser: options.hideFromUser ?? undefined,
forceShellIntegration: internalOptions?.forceShellIntegration ?? undefined,
isFeatureTerminal: internalOptions?.isFeatureTerminal ?? undefined,
isExtensionOwnedTerminal: true,
useShellEnvironment: internalOptions?.useShellEnvironment ?? undefined,
Expand Down
3 changes: 3 additions & 0 deletions src/vs/workbench/api/node/extHostDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export class ExtHostDebugService extends ExtHostDebugServiceBase {
giveShellTimeToInitialize = true;
terminal = this._terminalService.createTerminalFromOptions(options, {
isFeatureTerminal: true,
// Since debug termnials are REPLs, we want shell integration to be enabled.
// Ignore isFeatureTerminal when evaluating shell integration enablement.
forceShellIntegration: true,
useShellEnvironment: true
});
this._integratedTerminalInstances.insert(terminal, shellConfig);
Expand Down

0 comments on commit 5451a4e

Please sign in to comment.