Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a59c604

Browse files
committedJul 31, 2024·
Call FetchStackFramesAndVariablesAsync in Microsoft.PowerShell.EditorServices.Services.DebugService.SetVariableAsync and in Microsoft.PowerShell.EditorServices.Services.DebugService.EvaluateExpressionAsync to invalidate variables cache and use actual variables data.
1 parent 41fce39 commit a59c604

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
 

‎src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

+8
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ public async Task<string> SetVariableAsync(int variableContainerReferenceId, str
481481
// This makes the returned string consistent with the strings normally displayed for variables in the debugger.
482482
VariableDetails tempVariable = new(psVariable);
483483
_logger.LogTrace($"Set variable '{name}' to: {tempVariable.ValueString ?? "<null>"}");
484+
485+
// Fetch stack frames and variables again to have actual data in the variables field.
486+
// Without this, GetVariables and other methods that use the variables field will use old data.
487+
await FetchStackFramesAndVariablesAsync(null).ConfigureAwait(false);
484488
return tempVariable.ValueString;
485489
}
486490

@@ -508,6 +512,10 @@ public async Task<VariableDetails> EvaluateExpressionAsync(
508512
command,
509513
cancellationToken,
510514
new PowerShellExecutionOptions { WriteOutputToHost = writeResultAsOutput, ThrowOnError = !writeResultAsOutput }).ConfigureAwait(false);
515+
516+
// Fetch stack frames and variables again to have actual data in the variables field.
517+
// Without this, GetVariables and other methods that use the variables field will use old data.
518+
await FetchStackFramesAndVariablesAsync(null).ConfigureAwait(false);
511519
}
512520
catch (Exception e)
513521
{

0 commit comments

Comments
 (0)
Please sign in to comment.