diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs b/src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs index 43c54c17a..90faceda4 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs @@ -527,11 +527,15 @@ public async Task EvaluateExpressionAsync( return null; } - // If we didn't write output, - // return a VariableDetails instance. + // If we didn't write output, return a VariableDetails instance. return new VariableDetails( - expressionString, - string.Join(Environment.NewLine, results)); + expressionString, + // If there's only one result, we want its raw value (especially if it's null). For + // a collection, since we're displaying these, we want to concatenante them. + // However, doing that for one result caused null to be turned into an empty string. + results.Count == 1 + ? results[0] + : string.Join(Environment.NewLine, results)); } /// diff --git a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebugEvaluateHandler.cs b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebugEvaluateHandler.cs index cd91809fd..78c55c1f1 100644 --- a/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebugEvaluateHandler.cs +++ b/src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DebugEvaluateHandler.cs @@ -22,6 +22,7 @@ internal class DebugEvaluateHandler : IEvaluateHandler private readonly IInternalPowerShellExecutionService _executionService; private readonly DebugService _debugService; + // AKA Watch Variables public DebugEvaluateHandler( ILoggerFactory factory, IPowerShellDebugContext debugContext, diff --git a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs index b6a1aa48d..30b020c30 100644 --- a/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs +++ b/test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs @@ -529,7 +529,7 @@ await debugService.SetCommandBreakpointsAsync( AssertDebuggerStopped(testScript.FilePath, 11); VariableDetails prompt = await debugService.EvaluateExpressionAsync("prompt", false, CancellationToken.None); - Assert.Equal("\"True > \"", prompt.ValueString); + Assert.Equal("True > ", prompt.ValueString); } [SkippableFact]