Skip to content

Commit 757dd06

Browse files
Only check a script's extension if a script file was given (#4227)
Since it could be an inline script.
1 parent 68b5712 commit 757dd06

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/features/DebugSession.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import Settings = require("../settings");
1515
import { Logger } from "../logging";
1616
import { LanguageClientConsumer } from "../languageClientConsumer";
1717
import path = require("path");
18+
import utils = require("../utils");
1819

1920
export const StartDebuggerNotificationType =
2021
new NotificationType<void>("powerShell/startDebugger");
@@ -244,17 +245,21 @@ export class DebugSessionFeature extends LanguageClientConsumer
244245
}
245246

246247
// Check the temporary console setting for untitled documents only, and
247-
// check the document extension for everything else.
248+
// check the document extension for if the script is an extant file (it
249+
// could be inline).
248250
if (config.untitled_document) {
249251
if (config.createTemporaryIntegratedConsole) {
250252
await vscode.window.showErrorMessage("Debugging untitled files in a temporary console is not supported.");
251253
return undefined;
252254
}
253255
} else if (config.script) {
254-
const ext = path.extname(config.script).toLowerCase();
255-
if (!(ext === ".ps1" || ext === ".psm1")) {
256-
await vscode.window.showErrorMessage(`PowerShell does not support debugging this file type: '${path.basename(config.script)}'`);
257-
return undefined;
256+
// TODO: Why even bother with this complexity?
257+
if (await utils.checkIfFileExists(config.script)) {
258+
const ext = path.extname(config.script).toLowerCase();
259+
if (!(ext === ".ps1" || ext === ".psm1")) {
260+
await vscode.window.showErrorMessage(`PowerShell does not support debugging this file type: '${path.basename(config.script)}'`);
261+
return undefined;
262+
}
258263
}
259264
}
260265

0 commit comments

Comments
 (0)