Skip to content

Commit cae9aab

Browse files
authored
Fix variable's 'add to watch' feature. (#504)
* Fix variable's 'add to watch' feature. Fix #838. * Use results.Any() instead of .Count(), better perf.
1 parent ca71c9e commit cae9aab

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/PowerShellEditorServices.Protocol/DebugAdapter/Variable.cs

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public class Variable
1212
// /** The variable's value. For structured objects this can be a multi line text, e.g. for a function the body of a function. */
1313
public string Value { get; set; }
1414

15+
/// <summary>
16+
/// Gets or sets the evaluatable name for the variable that will be evaluated by the debugger.
17+
/// </summary>
18+
public string EvaluateName { get; set; }
19+
1520
// /** If variablesReference is > 0, the variable is structured and its children can be retrieved by passing variablesReference to the VariablesRequest. */
1621
public int VariablesReference { get; set; }
1722

@@ -21,6 +26,7 @@ public static Variable Create(VariableDetailsBase variable)
2126
{
2227
Name = variable.Name,
2328
Value = variable.ValueString ?? string.Empty,
29+
EvaluateName = variable.Name,
2430
VariablesReference =
2531
variable.IsExpandable ?
2632
variable.Id : 0

src/PowerShellEditorServices/Debugging/DebugService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ await this.powerShellContext.ExecuteScriptString(
603603
// of command executions into string output. However, if null is returned
604604
// then return null so that no output gets displayed.
605605
string outputString =
606-
results != null ?
606+
results != null && results.Any() ?
607607
string.Join(Environment.NewLine, results) :
608608
null;
609609

0 commit comments

Comments
 (0)