@@ -36,31 +36,25 @@ export class CodeExecutionManager implements ICodeExecutionManager {
3636 }
3737
3838 public registerCommands ( ) {
39- [ Commands . Exec_In_Terminal , Commands . Exec_In_Terminal_Icon , Commands . Exec_In_Separate_Terminal ] . forEach (
40- ( cmd ) => {
41- this . disposableRegistry . push (
42- this . commandManager . registerCommand ( cmd as any , async ( file : Resource ) => {
43- const interpreterService = this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
44- const interpreter = await interpreterService . getActiveInterpreter ( file ) ;
45- if ( ! interpreter ) {
46- this . commandManager
47- . executeCommand ( Commands . TriggerEnvironmentSelection , file )
48- . then ( noop , noop ) ;
49- return ;
50- }
51- const trigger = cmd === Commands . Exec_In_Terminal ? 'command' : 'icon' ;
52- await this . executeFileInTerminal ( file , trigger , {
53- newTerminalPerFile : cmd === Commands . Exec_In_Separate_Terminal ,
39+ [ Commands . Exec_In_Terminal , Commands . Exec_In_Terminal_Icon ] . forEach ( ( cmd ) => {
40+ this . disposableRegistry . push (
41+ this . commandManager . registerCommand ( cmd as any , async ( file : Resource ) => {
42+ const interpreterService = this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
43+ const interpreter = await interpreterService . getActiveInterpreter ( file ) ;
44+ if ( ! interpreter ) {
45+ this . commandManager . executeCommand ( Commands . TriggerEnvironmentSelection , file ) . then ( noop , noop ) ;
46+ return ;
47+ }
48+ const trigger = cmd === Commands . Exec_In_Terminal ? 'command' : 'icon' ;
49+ await this . executeFileInTerminal ( file , trigger )
50+ . then ( ( ) => {
51+ if ( this . shouldTerminalFocusOnStart ( file ) )
52+ this . commandManager . executeCommand ( 'workbench.action.terminal.focus' ) ;
5453 } )
55- . then ( ( ) => {
56- if ( this . shouldTerminalFocusOnStart ( file ) )
57- this . commandManager . executeCommand ( 'workbench.action.terminal.focus' ) ;
58- } )
59- . catch ( ( ex ) => traceError ( 'Failed to execute file in terminal' , ex ) ) ;
60- } ) ,
61- ) ;
62- } ,
63- ) ;
54+ . catch ( ( ex ) => traceError ( 'Failed to execute file in terminal' , ex ) ) ;
55+ } ) ,
56+ ) ;
57+ } ) ;
6458 this . disposableRegistry . push (
6559 this . commandManager . registerCommand ( Commands . Exec_Selection_In_Terminal as any , async ( file : Resource ) => {
6660 const interpreterService = this . serviceContainer . get < IInterpreterService > ( IInterpreterService ) ;
@@ -93,16 +87,8 @@ export class CodeExecutionManager implements ICodeExecutionManager {
9387 ) ,
9488 ) ;
9589 }
96- private async executeFileInTerminal (
97- file : Resource ,
98- trigger : 'command' | 'icon' ,
99- options ?: { newTerminalPerFile : boolean } ,
100- ) : Promise < void > {
101- sendTelemetryEvent ( EventName . EXECUTION_CODE , undefined , {
102- scope : 'file' ,
103- trigger,
104- newTerminalPerFile : options ?. newTerminalPerFile ,
105- } ) ;
90+ private async executeFileInTerminal ( file : Resource , trigger : 'command' | 'icon' ) {
91+ sendTelemetryEvent ( EventName . EXECUTION_CODE , undefined , { scope : 'file' , trigger } ) ;
10692 const codeExecutionHelper = this . serviceContainer . get < ICodeExecutionHelper > ( ICodeExecutionHelper ) ;
10793 file = file instanceof Uri ? file : undefined ;
10894 let fileToExecute = file ? file : await codeExecutionHelper . getFileToExecute ( ) ;
@@ -124,7 +110,7 @@ export class CodeExecutionManager implements ICodeExecutionManager {
124110 }
125111
126112 const executionService = this . serviceContainer . get < ICodeExecutionService > ( ICodeExecutionService , 'standard' ) ;
127- await executionService . executeFile ( fileToExecute , options ) ;
113+ await executionService . executeFile ( fileToExecute ) ;
128114 }
129115
130116 @captureTelemetry ( EventName . EXECUTION_CODE , { scope : 'selection' } , false )
0 commit comments