Skip to content

Commit eddd981

Browse files
committed
Fix regression with F5 to use . instead of & operator
This also corrects the scope of the script's parameter variables to be `Local` instead of `Command` in the `DebuggerAcceptsScriptArgs` test, as it was prior to v3.0.
1 parent 3c4e48e commit eddd981

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ internal class DebugService
4545
private int nextVariableId;
4646
private string temporaryScriptListingPath;
4747
private List<VariableDetailsBase> variables;
48-
internal VariableContainerDetails globalScopeVariables; // Internal for unit testing.
48+
private VariableContainerDetails globalScopeVariables;
4949
private VariableContainerDetails scriptScopeVariables;
5050
private VariableContainerDetails localScopeVariables;
5151
private StackFrameDetails[] stackFrameDetails;

src/PowerShellEditorServices/Utility/PSCommandExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public static PSCommand BuildCommandFromArguments(string command, IReadOnlyList<
137137
// HACK: We use AddScript instead of AddArgument/AddParameter to reuse Powershell parameter binding logic.
138138
// We quote the command parameter so that expressions can still be used in the arguments.
139139
var sb = new StringBuilder()
140-
.Append('&')
140+
.Append('.')
141141
.Append(' ')
142142
.Append('"')
143143
.Append(command)

test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ await debugService.SetCommandBreakpointsAsync(
158158

159159
StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
160160
Assert.Equal(StackFrameDetails.NoFileScriptPath, stackFrames[0].ScriptPath);
161-
VariableDetailsBase[] variables = debugService.GetVariables(debugService.globalScopeVariables.Id);
161+
162+
VariableScope[] scopes = debugService.GetVariableScopes(0);
163+
VariableScope globalScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.GlobalScopeName);
164+
VariableDetailsBase[] variables = debugService.GetVariables(globalScope.Id);
162165

163166
// NOTE: This assertion will fail if any error occurs. Notably this happens in testing
164167
// when the assembly path changes and the commands definition file can't be found.
@@ -197,8 +200,9 @@ public async Task DebuggerAcceptsScriptArgs()
197200

198201
AssertDebuggerStopped(debugWithParamsFile.FilePath, 3);
199202

200-
StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
201-
VariableDetailsBase[] variables = debugService.GetVariables(stackFrames[0].AutoVariables.Id);
203+
VariableScope[] scopes = debugService.GetVariableScopes(0);
204+
VariableScope localScope = Array.Find(scopes, s => s.Name == VariableContainerDetails.LocalScopeName);
205+
VariableDetailsBase[] variables = debugService.GetVariables(localScope.Id);
202206

203207
var var = Array.Find(variables, v => v.Name == "$Param1");
204208
Assert.NotNull(var);
@@ -220,6 +224,7 @@ public async Task DebuggerAcceptsScriptArgs()
220224
Assert.True(var.IsExpandable);
221225

222226
// NOTE: $args are no longer found in AutoVariables but CommandVariables instead.
227+
StackFrameDetails[] stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
223228
variables = debugService.GetVariables(stackFrames[0].CommandVariables.Id);
224229
var = Array.Find(variables, v => v.Name == "$args");
225230
Assert.NotNull(var);
@@ -618,9 +623,8 @@ await debugService.SetLineBreakpointsAsync(
618623
debugService.StepOver();
619624
AssertDebuggerStopped(variableScriptFile.FilePath);
620625

621-
stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
622-
623626
// Test set of a local string variable (not strongly typed)
627+
stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
624628
variables = debugService.GetVariables(stackFrames[0].AutoVariables.Id);
625629
var strVar = Array.Find(variables, v => v.Name == "$strVar");
626630
Assert.Equal(newStrValue, strVar.ValueString);
@@ -682,9 +686,8 @@ await debugService.SetLineBreakpointsAsync(
682686
debugService.StepOver();
683687
AssertDebuggerStopped(variableScriptFile.FilePath);
684688

685-
stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
686-
687689
// Test set of a local string variable (not strongly typed but force conversion)
690+
stackFrames = await debugService.GetStackFramesAsync().ConfigureAwait(true);
688691
variables = debugService.GetVariables(stackFrames[0].AutoVariables.Id);
689692
var strVar = Array.Find(variables, v => v.Name == "$strVar2");
690693
Assert.Equal(newStrValue, strVar.ValueString);

0 commit comments

Comments
 (0)