Skip to content

Commit cf95f1b

Browse files
authored
Merge pull request #649 from daviwil/fix-648
Fix error when debugging untitled script with no launch.json
2 parents 030cbf7 + 63627d9 commit cf95f1b

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# vscode-powershell Release History
22

3+
## 0.12.1
4+
### Tuesday, April 4, 2017
5+
6+
- Fixed [#648](https://github.com/PowerShell/vscode-powershell/issues/648) -
7+
Resolved an error when launching an untitled script file in a workspace
8+
with no launch.json or in a window without a workspace path
9+
310
## 0.12.0
411
### Tuesday, April 4, 2017
512

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '0.12.0-insiders-{build}'
1+
version: '0.12.1-insiders-{build}'
22
image: Visual Studio 2017
33
clone_depth: 10
44
skip_tags: true

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "PowerShell",
33
"displayName": "PowerShell",
4-
"version": "0.12.0",
4+
"version": "0.12.1",
55
"publisher": "ms-vscode",
66
"description": "Develop PowerShell scripts in Visual Studio Code!",
77
"engines": {

src/features/DebugSession.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ export class DebugSessionFeature implements IFeature {
2525

2626
private startDebugSession(config: any) {
2727

28+
let currentDocument = vscode.window.activeTextEditor.document;
29+
2830
if (!config.request) {
2931
// No launch.json, create the default configuration
3032
config.type = 'PowerShell';
3133
config.name = 'PowerShell Launch Current File';
3234
config.request = 'launch';
3335
config.args = [];
34-
config.script = vscode.window.activeTextEditor.document.fileName;
36+
37+
config.script =
38+
currentDocument.isUntitled
39+
? currentDocument.uri.toString()
40+
: currentDocument.fileName;
3541
}
3642

3743
if (config.request === 'launch') {
@@ -41,7 +47,6 @@ export class DebugSessionFeature implements IFeature {
4147
// For launch of "current script", don't start the debugger if the current file
4248
// is not a file that can be debugged by PowerShell
4349
if (config.script === "${file}") {
44-
let currentDocument = vscode.window.activeTextEditor.document;
4550

4651
if (currentDocument.isUntitled) {
4752
if (currentDocument.languageId === 'powershell') {

0 commit comments

Comments
 (0)