提交 2d94a3d6 编写于 作者: G Gunnar Wagenknecht

Store expansion state globally only when there are items.

When a debugger needs more time while stepping, the tree will go empty first
(while running) and then come back with data (when stopped again). This
modifies the change for #16031 to allow the tree to properly restore
state in case a debugger needs more time providing content.

The expanded state is saved in a global variable. A check ensures that an
intermittent empty tree does not override the global variable. Future refreshes
of an empty tree will then restore the expanded state of variables.
上级 7527e600
......@@ -47,6 +47,7 @@ export class VariablesView extends ViewsViewletPanel {
private onFocusStackFrameScheduler: RunOnceScheduler;
private variablesFocusedContext: IContextKey<boolean>;
private settings: any;
private expandedElements: any[];
constructor(
private options: IViewletViewOptions,
......@@ -63,14 +64,18 @@ export class VariablesView extends ViewsViewletPanel {
this.settings = options.viewletSettings;
this.variablesFocusedContext = CONTEXT_VARIABLES_FOCUSED.bindTo(contextKeyService);
this.expandedElements = [];
// Use scheduler to prevent unnecessary flashing
this.onFocusStackFrameScheduler = new RunOnceScheduler(() => {
// Remember expanded elements when there are some (otherwise don't override/erase the previous ones)
if (this.tree.getExpandedElements().length > 0) {
this.expandedElements = this.tree.getExpandedElements();
}
// Always clear tree highlight to avoid ending up in a broken state #12203
this.tree.clearHighlight();
const expanded = this.tree.getExpandedElements();
this.tree.refresh().then(() => {
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
return sequence(expanded.map(e => () => this.tree.expand(e))).then(() => {
return sequence(this.expandedElements.map(e => () => this.tree.expand(e))).then(() => {
// If there is no preserved expansion state simply expand the first scope
if (stackFrame && this.tree.getExpandedElements().length === 0) {
return stackFrame.getScopes().then(scopes => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册