File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,25 @@ export class DebugSessionFeature implements IFeature {
3636 if ( config . request === 'launch' ) {
3737 // Make sure there's a usable working directory if possible
3838 config . cwd = config . cwd || vscode . workspace . rootPath || config . script ;
39+
40+ // For launch of "current script", don't start the debugger if the current file
41+ // is not a file that can be debugged by PowerShell
42+ if ( config . script === "${file}" ) {
43+ let filename = vscode . window . activeTextEditor . document . fileName ;
44+ let ext = filename . substr ( filename . lastIndexOf ( '.' ) + 1 ) ;
45+ let langId = vscode . window . activeTextEditor . document . languageId ;
46+ if ( ( langId !== 'powershell' ) || ( ext !== "ps1" && ext !== "psm1" ) ) {
47+ let path = filename ;
48+ let workspaceRootPath = vscode . workspace . rootPath ;
49+ if ( filename . startsWith ( workspaceRootPath ) ) {
50+ path = filename . substring ( vscode . workspace . rootPath . length + 1 ) ;
51+ }
52+
53+ let msg = "'" + path + "' is a file type that cannot be debugged by the PowerShell debugger." ;
54+ vscode . window . showErrorMessage ( msg ) ;
55+ return ;
56+ }
57+ }
3958 }
4059
4160 vscode . commands . executeCommand ( 'vscode.startDebug' , config ) ;
You can’t perform that action at this time.
0 commit comments