Skip to content

Commit

Permalink
add _shellIntegrationEnabled
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonykim1 committed Oct 30, 2024
1 parent 59a3116 commit 4fd5369
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export class TerminalService implements ITerminalService, Disposable {
private terminalActivator: ITerminalActivator;
private terminalAutoActivator: ITerminalAutoActivation;
private readonly executeCommandListeners: Set<Disposable> = new Set();
private _shellIntegrationEnabled: boolean = false;
public get onDidCloseTerminal(): Event<void> {
return this.terminalClosed.event.bind(this.terminalClosed);
}

// private _shellIntegrationEnabled
constructor(
@inject(IServiceContainer) private serviceContainer: IServiceContainer,
private readonly options?: TerminalCreationOptions,
Expand Down Expand Up @@ -81,15 +81,17 @@ export class TerminalService implements ITerminalService, Disposable {
}

// If terminal was just launched, wait some time for shell integration to onDidChangeShellIntegration.
if (!terminal.shellIntegration) {
if (!terminal.shellIntegration && !this._shellIntegrationEnabled) {
const promise = new Promise<boolean>((resolve) => {
const disposable = this.terminalManager.onDidChangeTerminalShellIntegration(() => {
this._shellIntegrationEnabled = true;
clearTimeout(timer); //racetimeout
disposable.dispose();
resolve(true);
});
const TIMEOUT_DURATION = 500;
const timer = setTimeout(() => {
this._shellIntegrationEnabled = false;
disposable.dispose();
resolve(true);
}, TIMEOUT_DURATION);
Expand All @@ -101,8 +103,10 @@ export class TerminalService implements ITerminalService, Disposable {
// TODO: executeCommand would not execute command manually typed inside Python Terminal REPL.
// We only run executeCommand when user shift+enter in .py file, and hence run command in terminal on user's behalf.
const execution = terminal.shellIntegration.executeCommand(commandLine);
this._shellIntegrationEnabled = true;
return execution;
} else {
this._shellIntegrationEnabled = false;
terminal.sendText(commandLine);
traceVerbose(`Shell Integration is disabled, sendText: ${commandLine}`);
}
Expand Down

0 comments on commit 4fd5369

Please sign in to comment.