Skip to content

Commit 203877b

Browse files
committed
When the built-in $null was watched its value was incorrect
No idea _why_ its value was `""`, but it was, so we special case it and return `$null` just like you get from watched variables that were assigned the built-in `$null`.
1 parent 0fa5751 commit 203877b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebugEvaluateHandler.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ internal class DebugEvaluateHandler : IEvaluateHandler
2222
private readonly IInternalPowerShellExecutionService _executionService;
2323
private readonly DebugService _debugService;
2424

25+
// AKA Watch Variables
2526
public DebugEvaluateHandler(
2627
ILoggerFactory factory,
2728
IPowerShellDebugContext debugContext,
@@ -72,7 +73,10 @@ await _executionService.ExecutePSCommandAsync(
7273

7374
if (result != null)
7475
{
75-
valueString = result.ValueString;
76+
// For some reason the built-in "$null" variable when inspected in this way has
77+
// a value type of System.String instead of being null (which user variables
78+
// with the value of $null have).
79+
valueString = string.Equals(result.Name, "$null") ? "$null" : result.ValueString;
7680
variableId = result.IsExpandable ? result.Id : 0;
7781
}
7882
}

0 commit comments

Comments
 (0)