@@ -40,15 +40,18 @@ export class CodeExecutionManager implements ICodeExecutionManager {
4040 ( cmd ) => {
4141 this . disposableRegistry . push (
4242 this . commandManager . registerCommand ( cmd as any , async ( file : Resource ) => {
43+ console . log ( `[EXEC] Command ${ cmd } triggered with file: ${ file ?. fsPath } ` ) ;
4344 traceVerbose ( `Attempting to run Python file` , file ?. fsPath ) ;
4445 const trigger = cmd === Commands . Exec_In_Terminal ? 'command' : 'icon' ;
4546 const newTerminalPerFile = cmd === Commands . Exec_In_Separate_Terminal ;
4647
4748 if ( useEnvExtension ( ) ) {
49+ console . log ( '[EXEC] Using Environment Extension to execute file in terminal' ) ;
4850 traceVerbose ( 'Using Environment Extension to execute file in terminal' ) ;
4951 try {
5052 await this . executeUsingExtension ( file , cmd === Commands . Exec_In_Separate_Terminal ) ;
5153 } catch ( ex ) {
54+ console . error ( '[EXEC] Failed to execute file in terminal' , ex ) ;
5255 traceError ( 'Failed to execute file in terminal' , ex ) ;
5356 }
5457 sendTelemetryEvent ( EventName . ENVIRONMENT_CHECK_TRIGGER , undefined , {
@@ -125,53 +128,72 @@ export class CodeExecutionManager implements ICodeExecutionManager {
125128 }
126129
127130 private async executeUsingExtension ( file : Resource , dedicated : boolean ) : Promise < void > {
131+ console . log ( `[EXEC] executeUsingExtension called with file: ${ file ?. fsPath } , dedicated: ${ dedicated } ` ) ;
128132 traceVerbose ( `executeUsingExtension called with file: ${ file ?. fsPath } , dedicated: ${ dedicated } ` ) ;
129133 const codeExecutionHelper = this . serviceContainer . get < ICodeExecutionHelper > ( ICodeExecutionHelper ) ;
130134 file = file instanceof Uri ? file : undefined ;
131135 let fileToExecute = file ? file : await codeExecutionHelper . getFileToExecute ( ) ;
132136 if ( ! fileToExecute ) {
137+ console . log ( '[EXEC] executeUsingExtension: No file to execute, returning early' ) ;
133138 traceVerbose ( 'executeUsingExtension: No file to execute, returning early' ) ;
134139 return ;
135140 }
141+ console . log ( `[EXEC] executeUsingExtension: File to execute: ${ fileToExecute . fsPath } ` ) ;
136142 traceVerbose ( `executeUsingExtension: File to execute: ${ fileToExecute . fsPath } ` ) ;
137143
138144 const fileAfterSave = await codeExecutionHelper . saveFileIfDirty ( fileToExecute ) ;
139145 if ( fileAfterSave ) {
146+ console . log ( `[EXEC] executeUsingExtension: File saved, updated path: ${ fileAfterSave . fsPath } ` ) ;
140147 traceVerbose ( `executeUsingExtension: File saved, updated path: ${ fileAfterSave . fsPath } ` ) ;
141148 fileToExecute = fileAfterSave ;
142149 }
143150
144151 // Check on setting terminal.executeInFileDir
145152 const pythonSettings = this . configSettings . getSettings ( file ) ;
146153 let cwd = pythonSettings . terminal . executeInFileDir ? path . dirname ( fileToExecute . fsPath ) : undefined ;
154+ console . log (
155+ `[EXEC] executeUsingExtension: CWD: ${ cwd } , executeInFileDir: ${ pythonSettings . terminal . executeInFileDir } ` ,
156+ ) ;
147157 traceVerbose (
148158 `executeUsingExtension: CWD: ${ cwd } , executeInFileDir: ${ pythonSettings . terminal . executeInFileDir } ` ,
149159 ) ;
150160
151161 // Check on setting terminal.launchArgs
152162 const launchArgs = pythonSettings . terminal . launchArgs ;
153163 const totalArgs = [ ...launchArgs , fileToExecute . fsPath . fileToCommandArgumentForPythonExt ( ) ] ;
164+ console . log (
165+ `[EXEC] executeUsingExtension: Launch args: ${ JSON . stringify ( launchArgs ) } , Total args: ${ JSON . stringify (
166+ totalArgs ,
167+ ) } `,
168+ ) ;
154169 traceVerbose (
155170 `executeUsingExtension: Launch args: ${ JSON . stringify ( launchArgs ) } , Total args: ${ JSON . stringify (
156171 totalArgs ,
157172 ) } `,
158173 ) ;
159174
160175 const show = this . shouldTerminalFocusOnStart ( fileToExecute ) ;
176+ console . log (
177+ `[EXEC] executeUsingExtension: Terminal focus on start: ${ show } , Using dedicated terminal: ${ dedicated } ` ,
178+ ) ;
161179 traceVerbose ( `executeUsingExtension: Terminal focus on start: ${ show } , Using dedicated terminal: ${ dedicated } ` ) ;
162180 let terminal : Terminal | undefined ;
163181 if ( dedicated ) {
182+ console . log ( '[EXEC] executeUsingExtension: Calling runInDedicatedTerminal' ) ;
164183 traceVerbose ( 'executeUsingExtension: Calling runInDedicatedTerminal' ) ;
165184 terminal = await runInDedicatedTerminal ( fileToExecute , totalArgs , cwd , show ) ;
166185 } else {
186+ console . log ( '[EXEC] executeUsingExtension: Calling runInTerminal' ) ;
167187 traceVerbose ( 'executeUsingExtension: Calling runInTerminal' ) ;
168188 terminal = await runInTerminal ( fileToExecute , totalArgs , cwd , show ) ;
169189 }
170190
171191 if ( terminal ) {
192+ console . log ( `[EXEC] executeUsingExtension: Terminal created successfully, showing terminal` ) ;
172193 traceVerbose ( `executeUsingExtension: Terminal created successfully, showing terminal` ) ;
173194 terminal . show ( ) ;
174195 } else {
196+ console . log ( '[EXEC] executeUsingExtension: No terminal returned from run function' ) ;
175197 traceVerbose ( 'executeUsingExtension: No terminal returned from run function' ) ;
176198 }
177199 }
0 commit comments