@@ -7,12 +7,11 @@ import {
77 TerminalShellExecutionStartEvent ,
88 TerminalShellIntegration ,
99} from 'vscode' ;
10- import { PythonCommandRunConfiguration , PythonEnvironment } from '../../api' ;
11- import { onDidEndTerminalShellExecution , onDidStartTerminalShellExecution } from '../../common/window.apis' ;
10+ import { PythonEnvironment } from '../../api' ;
1211import { traceError , traceInfo , traceVerbose } from '../../common/logging' ;
13- import { isTaskTerminal } from './utils ' ;
12+ import { onDidEndTerminalShellExecution , onDidStartTerminalShellExecution } from '../../common/window.apis ' ;
1413import { getActivationCommand , getDeactivationCommand } from '../common/activation' ;
15- import { quoteArgs } from '../execution/execUtils ' ;
14+ import { isTaskTerminal } from './utils ' ;
1615
1716export interface DidChangeTerminalActivationStateEvent {
1817 terminal : Terminal ;
@@ -92,11 +91,6 @@ export class TerminalActivationImpl implements TerminalActivationInternal {
9291 return ;
9392 }
9493
95- if ( terminal . shellIntegration ?. env ?. value ?. [ 'TERM_PROGRAM' ] !== 'vscode' ) {
96- traceVerbose ( 'Terminal is not a VS Code terminal, skipping activation' ) ;
97- return ;
98- }
99-
10094 if ( this . deactivatingTerminals . has ( terminal ) ) {
10195 traceVerbose ( 'Terminal is being deactivated, cannot activate.' ) ;
10296 return this . deactivatingTerminals . get ( terminal ) ;
@@ -203,23 +197,15 @@ export class TerminalActivationImpl implements TerminalActivationInternal {
203197 private activateLegacy ( terminal : Terminal , environment : PythonEnvironment ) {
204198 const activationCommands = getActivationCommand ( terminal , environment ) ;
205199 if ( activationCommands ) {
206- for ( const command of activationCommands ) {
207- const args = command . args ?? [ ] ;
208- const text = quoteArgs ( [ command . executable , ...args ] ) . join ( ' ' ) ;
209- terminal . sendText ( text ) ;
210- }
200+ terminal . sendText ( activationCommands ) ;
211201 this . activatedTerminals . set ( terminal , environment ) ;
212202 }
213203 }
214204
215205 private deactivateLegacy ( terminal : Terminal , environment : PythonEnvironment ) {
216206 const deactivationCommands = getDeactivationCommand ( terminal , environment ) ;
217207 if ( deactivationCommands ) {
218- for ( const command of deactivationCommands ) {
219- const args = command . args ?? [ ] ;
220- const text = quoteArgs ( [ command . executable , ...args ] ) . join ( ' ' ) ;
221- terminal . sendText ( text ) ;
222- }
208+ terminal . sendText ( deactivationCommands ) ;
223209 this . activatedTerminals . delete ( terminal ) ;
224210 }
225211 }
@@ -229,12 +215,10 @@ export class TerminalActivationImpl implements TerminalActivationInternal {
229215 terminal : Terminal ,
230216 environment : PythonEnvironment ,
231217 ) : Promise < void > {
232- const activationCommands = getActivationCommand ( terminal , environment ) ;
233- if ( activationCommands ) {
218+ const activationCommand = getActivationCommand ( terminal , environment ) ;
219+ if ( activationCommand ) {
234220 try {
235- for ( const command of activationCommands ) {
236- await this . executeTerminalShellCommandInternal ( shellIntegration , command ) ;
237- }
221+ await this . executeTerminalShellCommandInternal ( shellIntegration , activationCommand ) ;
238222 this . activatedTerminals . set ( terminal , environment ) ;
239223 } catch {
240224 traceError ( 'Failed to activate environment using shell integration' ) ;
@@ -249,12 +233,10 @@ export class TerminalActivationImpl implements TerminalActivationInternal {
249233 terminal : Terminal ,
250234 environment : PythonEnvironment ,
251235 ) : Promise < void > {
252- const deactivationCommands = getDeactivationCommand ( terminal , environment ) ;
253- if ( deactivationCommands ) {
236+ const deactivationCommand = getDeactivationCommand ( terminal , environment ) ;
237+ if ( deactivationCommand ) {
254238 try {
255- for ( const command of deactivationCommands ) {
256- await this . executeTerminalShellCommandInternal ( shellIntegration , command ) ;
257- }
239+ await this . executeTerminalShellCommandInternal ( shellIntegration , deactivationCommand ) ;
258240 this . activatedTerminals . delete ( terminal ) ;
259241 } catch {
260242 traceError ( 'Failed to deactivate environment using shell integration' ) ;
@@ -266,14 +248,14 @@ export class TerminalActivationImpl implements TerminalActivationInternal {
266248
267249 private async executeTerminalShellCommandInternal (
268250 shellIntegration : TerminalShellIntegration ,
269- command : PythonCommandRunConfiguration ,
251+ command : string ,
270252 ) : Promise < boolean > {
271- const execution = shellIntegration . executeCommand ( command . executable , command . args ?? [ ] ) ;
253+ const execution = shellIntegration . executeCommand ( command ) ;
272254 const disposables : Disposable [ ] = [ ] ;
273255
274256 const promise = new Promise < void > ( ( resolve ) => {
275257 const timer = setTimeout ( ( ) => {
276- traceError ( `Shell execution timed out: ${ command . executable } ${ command . args ?. join ( ' ' ) } ` ) ;
258+ traceError ( `Shell execution timed out: ${ command } ` ) ;
277259 resolve ( ) ;
278260 } , 2000 ) ;
279261
@@ -286,7 +268,7 @@ export class TerminalActivationImpl implements TerminalActivationInternal {
286268 } ) ,
287269 this . onTerminalShellExecutionStart ( ( e : TerminalShellExecutionStartEvent ) => {
288270 if ( e . execution === execution ) {
289- traceVerbose ( `Shell execution started: ${ command . executable } ${ command . args ?. join ( ' ' ) } ` ) ;
271+ traceVerbose ( `Shell execution started: ${ command } ` ) ;
290272 }
291273 } ) ,
292274 ) ;
@@ -296,7 +278,7 @@ export class TerminalActivationImpl implements TerminalActivationInternal {
296278 await promise ;
297279 return true ;
298280 } catch {
299- traceError ( `Failed to execute shell command: ${ command . executable } ${ command . args ?. join ( ' ' ) } ` ) ;
281+ traceError ( `Failed to execute shell command: ${ command } ` ) ;
300282 return false ;
301283 } finally {
302284 disposables . forEach ( ( d ) => d . dispose ( ) ) ;
0 commit comments