Skip to content

First approach to fix issue with dbg/run start before PSES running #1436

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 1 commit into from
Jul 16, 2018
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
16 changes: 11 additions & 5 deletions src/features/DebugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { LanguageClient, NotificationType, RequestType } from "vscode-languagecl
import { IFeature } from "../feature";
import { getPlatformDetails, OperatingSystem } from "../platform";
import { PowerShellProcess} from "../process";
import { SessionManager } from "../session";
import { SessionManager, SessionStatus } from "../session";
import Settings = require("../settings");
import utils = require("../utils");

Expand Down Expand Up @@ -48,6 +48,14 @@ export class DebugSessionFeature implements IFeature, DebugConfigurationProvider
config: DebugConfiguration,
token?: CancellationToken): ProviderResult<DebugConfiguration> {

// Make sure there is a session running before attempting to debug/run a program
if (this.sessionManager.getSessionStatus() !== SessionStatus.Running) {
const msg = "Cannot debug or run a PowerShell script until the PowerShell session has started. " +
"Wait for the PowerShell session to finish starting and try again.";
vscode.window.showWarningMessage(msg);
return;
}

// Starting a debug session can be done when there is no document open e.g. attach to PS host process
const currentDocument = vscode.window.activeTextEditor ? vscode.window.activeTextEditor.document : undefined;
const debugCurrentScript = (config.script === "${file}") || !config.request;
Expand All @@ -60,10 +68,8 @@ export class DebugSessionFeature implements IFeature, DebugConfigurationProvider
const platformDetails = getPlatformDetails();
const versionDetails = this.sessionManager.getPowerShellVersionDetails();

if (versionDetails.edition.toLowerCase() === "core" &&
platformDetails.operatingSystem !== OperatingSystem.Windows) {

const msg = "PowerShell Core only supports attaching to a host process on Windows.";
if (platformDetails.operatingSystem !== OperatingSystem.Windows) {
const msg = "Attaching to a PowerShell Host Process is supported only on Windows.";
return vscode.window.showErrorMessage(msg).then((_) => {
return undefined;
});
Expand Down
4 changes: 4 additions & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ export class SessionManager implements Middleware {
return this.sessionDetails;
}

public getSessionStatus(): SessionStatus {
return this.sessionStatus;
}

public getPowerShellVersionDetails(): IPowerShellVersionDetails {
return this.versionDetails;
}
Expand Down