Skip to content

Commit 1e09454

Browse files
authored
Flag program in launch.json as an optional property (microsoft#1578)
Fixes microsoft#1503 Also fix a few other linter warnings/errors.
1 parent fffa444 commit 1e09454

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

news/3 Code Health/1503.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Flag `program` in `launch.json` configuration items as an optional attribute.

src/client/debugger/Common/Contracts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export interface BaseLaunchRequestArguments extends DebugProtocol.LaunchRequestA
7171
type?: DebuggerType;
7272
/** An absolute path to the program to debug. */
7373
module?: string;
74-
program: string;
74+
program?: string;
7575
pythonPath: string;
7676
/** Automatically stop target after launch. If not specified, target does not stop. */
7777
stopOnEntry?: boolean;

src/client/debugger/Main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class PythonDebugger extends LoggingDebugSession {
9292
private startDebugServer(): Promise<IDebugServer> {
9393
let programDirectory = '';
9494
if ((this.launchArgs && this.launchArgs.program) || (this.attachArgs && this.attachArgs.localRoot)) {
95-
programDirectory = this.launchArgs ? path.dirname(this.launchArgs.program) : this.attachArgs.localRoot;
95+
programDirectory = (this.launchArgs && this.launchArgs.program) ? path.dirname(this.launchArgs.program) : this.attachArgs.localRoot;
9696
}
9797
if (this.launchArgs && typeof this.launchArgs.cwd === 'string' && this.launchArgs.cwd.length > 0 && this.launchArgs.cwd !== 'null') {
9898
programDirectory = this.launchArgs.cwd;
@@ -227,7 +227,7 @@ export class PythonDebugger extends LoggingDebugSession {
227227
}
228228
// Confirm the file exists
229229
if (typeof args.module !== 'string' || args.module.length === 0) {
230-
if (!fs.existsSync(args.program)) {
230+
if (!args.program || !fs.existsSync(args.program)) {
231231
return this.sendErrorResponse(response, 2001, `File does not exist. "${args.program}"`);
232232
}
233233
}

src/client/workspaceSymbols/generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class Generator implements vscode.Disposable {
3131
if (!this.pythonSettings.workspaceSymbols.enabled) {
3232
return;
3333
}
34-
return await this.generateTags({ directory: this.workspaceFolder.fsPath });
34+
return this.generateTags({ directory: this.workspaceFolder.fsPath });
3535
}
3636
private buildCmdArgs(): string[] {
3737
const exclusions = this.pythonSettings.workspaceSymbols.exclusionPatterns;
@@ -40,7 +40,7 @@ export class Generator implements vscode.Disposable {
4040
return [`--options=${this.optionsFile}`, '--languages=Python'].concat(excludes);
4141
}
4242
@captureTelemetry(WORKSPACE_SYMBOLS_BUILD)
43-
private generateTags(source: { directory?: string, file?: string }): Promise<void> {
43+
private generateTags(source: { directory?: string; file?: string }): Promise<void> {
4444
const tagFile = path.normalize(this.pythonSettings.workspaceSymbols.tagFilePath);
4545
const cmd = this.pythonSettings.workspaceSymbols.ctagsPath;
4646
const args = this.buildCmdArgs();

0 commit comments

Comments
 (0)