Skip to content

Commit dc1cf30

Browse files
committed
Updated to address @daviwil suggestion to execute cd separately.
Also found two launch params that have been renamed (looking at 0.10.7-insiders mono-debug package.json file). Although I don't think runtimeArgs really applies to PowerShell debugging. The "runtimeExecutable" is the debug host and by the time the launch message comes along, it is already started.
1 parent 40ed35d commit dc1cf30

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/PowerShellEditorServices.Protocol/DebugAdapter/LaunchRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ public class LaunchRequestArguments
3333
public string RuntimeExecutable { get; set; }
3434

3535
// /** Optional arguments passed to the runtime executable. */
36-
public string[] RuntimeArguments { get; set; }
36+
public string[] RuntimeArgs { get; set; }
3737

3838
// /** Optional environment variables to pass to the debuggee. The string valued properties of the 'environmentVariables' are used as key/value pairs. */
39-
public Dictionary<string, string> EnvironmentVariables { get; set; }
39+
public Dictionary<string, string> Env { get; set; }
4040
}
4141
}
4242

src/PowerShellEditorServices.Protocol/Server/DebugAdapter.cs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,26 @@ protected async Task HandleLaunchRequest(
8282
setWorkingDirCommand.AddCommand(@"Microsoft.PowerShell.Management\Set-Location")
8383
.AddParameter("LiteralPath", workingDir);
8484

85+
await editorSession.PowerShellContext.ExecuteCommand(setWorkingDirCommand);
86+
87+
Logger.Write(LogLevel.Verbose, "Working dir set to '" + workingDir + "'");
88+
8589
// Execute the given PowerShell script and send the response.
8690
// Note that we aren't waiting for execution to complete here
8791
// because the debugger could stop while the script executes.
8892
Task executeTask =
8993
editorSession.PowerShellContext
90-
.ExecuteCommand(setWorkingDirCommand)
94+
.ExecuteScriptAtPath(launchParams.Program)
9195
.ContinueWith(
92-
(t1) => {
93-
Logger.Write(LogLevel.Verbose, "Working dir set to '" + workingDir + "'");
94-
95-
editorSession.PowerShellContext
96-
.ExecuteScriptAtPath(launchParams.Program)
97-
.ContinueWith(
98-
async (t2) => {
99-
Logger.Write(LogLevel.Verbose, "Execution completed, terminating...");
100-
101-
await requestContext.SendEvent(
102-
TerminatedEvent.Type,
103-
null);
104-
105-
// Stop the server
106-
this.Stop();
107-
});
96+
async (t) => {
97+
Logger.Write(LogLevel.Verbose, "Execution completed, terminating...");
98+
99+
await requestContext.SendEvent(
100+
TerminatedEvent.Type,
101+
null);
102+
103+
// Stop the server
104+
this.Stop();
108105
});
109106

110107
await requestContext.SendResult(null);

0 commit comments

Comments
 (0)