@@ -41,20 +41,26 @@ export class DebugSessionFeature implements IFeature {
41
41
// For launch of "current script", don't start the debugger if the current file
42
42
// is not a file that can be debugged by PowerShell
43
43
if ( config . script === "${file}" ) {
44
- let filename = vscode . window . activeTextEditor . document . fileName ;
45
- let ext = filename . substr ( filename . lastIndexOf ( '.' ) + 1 ) ;
46
- let langId = vscode . window . activeTextEditor . document . languageId ;
47
- if ( ( langId !== 'powershell' ) || ( ext !== "ps1" && ext !== "psm1" ) ) {
48
- let path = filename ;
44
+ let currentDocument = vscode . window . activeTextEditor . document ;
45
+ let ext =
46
+ currentDocument . fileName . substr (
47
+ currentDocument . fileName . lastIndexOf ( '.' ) + 1 ) ;
48
+
49
+ if ( ( currentDocument . languageId !== 'powershell' ) ||
50
+ ( ! currentDocument . isUntitled ) && ( ext !== "ps1" && ext !== "psm1" ) ) {
51
+ let path = currentDocument . fileName ;
49
52
let workspaceRootPath = vscode . workspace . rootPath ;
50
- if ( filename . startsWith ( workspaceRootPath ) ) {
51
- path = filename . substring ( vscode . workspace . rootPath . length + 1 ) ;
53
+ if ( currentDocument . fileName . startsWith ( workspaceRootPath ) ) {
54
+ path = currentDocument . fileName . substring ( vscode . workspace . rootPath . length + 1 ) ;
52
55
}
53
56
54
57
let msg = "'" + path + "' is a file type that cannot be debugged by the PowerShell debugger." ;
55
58
vscode . window . showErrorMessage ( msg ) ;
56
59
return ;
57
60
}
61
+ else if ( currentDocument . isUntitled ) {
62
+ config . script = currentDocument . uri . toString ( ) ;
63
+ }
58
64
}
59
65
}
60
66
0 commit comments