private async Task UpdateList()
{
if (_updating)
{
return;
}
try {
_updating = true;
// May be null in tests
var session = Workflow.RSession;
if (session.IsHostRunning)
{
var stackFrames = await session.TracebackAsync();
var globalStackFrame = stackFrames.FirstOrDefault(s => s.IsGlobal);
if (globalStackFrame != null)
{
const REvaluationResultProperties properties =
ExpressionProperty |
AccessorKindProperty |
TypeNameProperty |
ClassesProperty |
LengthProperty |
SlotCountProperty |
AttributeCountProperty |
DimProperty |
FlagsProperty;
var evaluation = await globalStackFrame.TryEvaluateAndDescribeAsync("base::environment()", "Global Environment", properties, RValueRepresentations.Str());
var settings = Workflow.Shell.GetService <IRSettings>();
var e = new RSessionDataObject(evaluation, settings.EvaluateActiveBindings); // root level doesn't truncate children and return every variables
_topLevelVariables.Clear();
var children = await e.GetChildrenAsync();
if (children != null)
{
foreach (var x in children)
{
_topLevelVariables[x.Name] = x; // TODO: BUGBUG: this doesn't address removed variables
}
}
}
}
} catch (REvaluationException) { } finally {
_updating = false;
}
}