@@ -24,7 +24,7 @@ export class DebugCommands implements IExtensionSingleActivationService {
24
24
25
25
public activate ( ) : Promise < void > {
26
26
this . disposables . push (
27
- this . commandManager . registerCommand ( Commands . Debug_In_Terminal , async ( file : Uri ) => {
27
+ this . commandManager . registerCommand ( Commands . Debug_In_Terminal , async ( file ? : Uri ) => {
28
28
sendTelemetryEvent ( EventName . DEBUG_IN_TERMINAL_BUTTON ) ;
29
29
const config = await this . getDebugConfiguration ( file ) ;
30
30
this . debugService . startDebugging ( undefined , config ) ;
@@ -33,13 +33,13 @@ export class DebugCommands implements IExtensionSingleActivationService {
33
33
return Promise . resolve ( ) ;
34
34
}
35
35
36
- private async getDebugConfiguration ( uri : Uri ) : Promise < DebugConfiguration > {
36
+ private async getDebugConfiguration ( uri ? : Uri ) : Promise < DebugConfiguration > {
37
37
const configs = ( await this . launchJsonReader . getConfigurationsByUri ( uri ) ) . filter ( ( c ) => c . request === 'launch' ) ;
38
38
for ( const config of configs ) {
39
39
if ( ( config as LaunchRequestArguments ) . purpose ?. includes ( DebugPurpose . DebugInTerminal ) ) {
40
40
if ( ! config . program && ! config . module && ! config . code ) {
41
41
// This is only needed if people reuse debug-test for debug-in-terminal
42
- config . program = uri . fsPath ;
42
+ config . program = uri ? .fsPath ?? '${file}' ;
43
43
}
44
44
// Ensure that the purpose is cleared, this is so we can track if people accidentally
45
45
// trigger this via F5 or Start with debugger.
@@ -48,10 +48,10 @@ export class DebugCommands implements IExtensionSingleActivationService {
48
48
}
49
49
}
50
50
return {
51
- name : `Debug ${ path . basename ( uri . fsPath ) } ` ,
51
+ name : `Debug ${ uri ? path . basename ( uri . fsPath ) : 'File' } ` ,
52
52
type : 'python' ,
53
53
request : 'launch' ,
54
- program : uri . fsPath ,
54
+ program : uri ? .fsPath ?? '${file}' ,
55
55
console : 'integratedTerminal' ,
56
56
} ;
57
57
}
0 commit comments