Skip to content

Fix error when debugging untitled script with no launch.json #649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# vscode-powershell Release History

## 0.12.1
### Tuesday, April 4, 2017

- Fixed [#648](https://github.com/PowerShell/vscode-powershell/issues/648) -
Resolved an error when launching an untitled script file in a workspace
with no launch.json or in a window without a workspace path

## 0.12.0
### Tuesday, April 4, 2017

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '0.12.0-insiders-{build}'
version: '0.12.1-insiders-{build}'
image: Visual Studio 2017
clone_depth: 10
skip_tags: true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "PowerShell",
"displayName": "PowerShell",
"version": "0.12.0",
"version": "0.12.1",
"publisher": "ms-vscode",
"description": "Develop PowerShell scripts in Visual Studio Code!",
"engines": {
Expand Down
9 changes: 7 additions & 2 deletions src/features/DebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ export class DebugSessionFeature implements IFeature {

private startDebugSession(config: any) {

let currentDocument = vscode.window.activeTextEditor.document;

if (!config.request) {
// No launch.json, create the default configuration
config.type = 'PowerShell';
config.name = 'PowerShell Launch Current File';
config.request = 'launch';
config.args = [];
config.script = vscode.window.activeTextEditor.document.fileName;

config.script =
currentDocument.isUntitled
? currentDocument.uri.toString()
: currentDocument.fileName;
}

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

if (currentDocument.isUntitled) {
if (currentDocument.languageId === 'powershell') {
Expand Down