Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/17374.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix to handle undefined uri in debug in terminal command.
2 changes: 1 addition & 1 deletion src/client/debugger/extension/configuration/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export interface IDebugConfigurationProviderFactory {
export const ILaunchJsonReader = Symbol('ILaunchJsonReader');
export interface ILaunchJsonReader {
getConfigurationsForWorkspace(workspace: WorkspaceFolder): Promise<DebugConfiguration[]>;
getConfigurationsByUri(uri: Uri): Promise<DebugConfiguration[]>;
getConfigurationsByUri(uri?: Uri): Promise<DebugConfiguration[]>;
}
10 changes: 5 additions & 5 deletions src/client/debugger/extension/debugCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class DebugCommands implements IExtensionSingleActivationService {

public activate(): Promise<void> {
this.disposables.push(
this.commandManager.registerCommand(Commands.Debug_In_Terminal, async (file: Uri) => {
this.commandManager.registerCommand(Commands.Debug_In_Terminal, async (file?: Uri) => {
sendTelemetryEvent(EventName.DEBUG_IN_TERMINAL_BUTTON);
const config = await this.getDebugConfiguration(file);
this.debugService.startDebugging(undefined, config);
Expand All @@ -33,13 +33,13 @@ export class DebugCommands implements IExtensionSingleActivationService {
return Promise.resolve();
}

private async getDebugConfiguration(uri: Uri): Promise<DebugConfiguration> {
private async getDebugConfiguration(uri?: Uri): Promise<DebugConfiguration> {
const configs = (await this.launchJsonReader.getConfigurationsByUri(uri)).filter((c) => c.request === 'launch');
for (const config of configs) {
if ((config as LaunchRequestArguments).purpose?.includes(DebugPurpose.DebugInTerminal)) {
if (!config.program && !config.module && !config.code) {
// This is only needed if people reuse debug-test for debug-in-terminal
config.program = uri.fsPath;
config.program = uri?.fsPath ?? '${file}';
}
// Ensure that the purpose is cleared, this is so we can track if people accidentally
// trigger this via F5 or Start with debugger.
Expand All @@ -48,10 +48,10 @@ export class DebugCommands implements IExtensionSingleActivationService {
}
}
return {
name: `Debug ${path.basename(uri.fsPath)}`,
name: `Debug ${uri ? path.basename(uri.fsPath) : 'File'}`,
type: 'python',
request: 'launch',
program: uri.fsPath,
program: uri?.fsPath ?? '${file}',
console: 'integratedTerminal',
};
}
Expand Down