mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 09:35:40 -05:00
Merge from vscode 4d91d96e5e121b38d33508cdef17868bab255eae
This commit is contained in:
committed by
AzureDataStudio
parent
a971aee5bd
commit
5e7071e466
@@ -8,8 +8,8 @@ import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { CollapseAction } from 'vs/workbench/browser/viewlet';
|
||||
import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewlet';
|
||||
import { IDebugService, IExpression, IScope, CONTEXT_VARIABLES_FOCUSED, IViewModel } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { Variable, Scope, ErrorScope } from 'vs/workbench/contrib/debug/common/debugModel';
|
||||
import { IDebugService, IExpression, IScope, CONTEXT_VARIABLES_FOCUSED, IStackFrame } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { Variable, Scope, ErrorScope, StackFrame } from 'vs/workbench/contrib/debug/common/debugModel';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { renderViewTree, renderVariable, IInputBoxOptions, AbstractExpressionsRenderer, IExpressionTemplateData } from 'vs/workbench/contrib/debug/browser/baseDebugView';
|
||||
@@ -34,6 +34,7 @@ import { IViewDescriptorService } from 'vs/workbench/common/views';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { withUndefinedAsNull } from 'vs/base/common/types';
|
||||
|
||||
const $ = dom.$;
|
||||
let forgetScopes = true;
|
||||
@@ -44,8 +45,9 @@ export class VariablesView extends ViewPane {
|
||||
|
||||
private onFocusStackFrameScheduler: RunOnceScheduler;
|
||||
private needsRefresh = false;
|
||||
private tree!: WorkbenchAsyncDataTree<IViewModel | IExpression | IScope, IExpression | IScope, FuzzyScore>;
|
||||
private savedViewState: IAsyncDataTreeViewState | undefined;
|
||||
private tree!: WorkbenchAsyncDataTree<IStackFrame | null, IExpression | IScope, FuzzyScore>;
|
||||
private savedViewState = new Map<string, IAsyncDataTreeViewState>();
|
||||
private autoExpandedScopes = new Set<string>();
|
||||
|
||||
constructor(
|
||||
options: IViewletViewOptions,
|
||||
@@ -68,26 +70,24 @@ export class VariablesView extends ViewPane {
|
||||
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
|
||||
|
||||
this.needsRefresh = false;
|
||||
if (stackFrame && this.savedViewState) {
|
||||
await this.tree.setInput(this.debugService.getViewModel(), this.savedViewState);
|
||||
this.savedViewState = undefined;
|
||||
} else {
|
||||
if (!stackFrame) {
|
||||
// We have no stackFrame, save tree state before it is cleared
|
||||
this.savedViewState = this.tree.getViewState();
|
||||
}
|
||||
await this.tree.updateChildren();
|
||||
if (stackFrame) {
|
||||
const scopes = await stackFrame.getScopes();
|
||||
// Expand the first scope if it is not expensive and if there is no expansion state (all are collapsed)
|
||||
if (scopes.every(s => this.tree.getNode(s).collapsed) && scopes.length > 0) {
|
||||
const toExpand = scopes.find(s => !s.expensive);
|
||||
if (toExpand) {
|
||||
this.tree.expand(toExpand);
|
||||
}
|
||||
}
|
||||
}
|
||||
const input = this.tree.getInput();
|
||||
if (input) {
|
||||
this.savedViewState.set(input.getId(), this.tree.getViewState());
|
||||
}
|
||||
if (!stackFrame) {
|
||||
await this.tree.setInput(null);
|
||||
return;
|
||||
}
|
||||
|
||||
const viewState = this.savedViewState.get(stackFrame.getId());
|
||||
await this.tree.setInput(stackFrame, viewState);
|
||||
|
||||
// Automatically expand the first scope if it is not expensive and if all scopes are collapsed
|
||||
const scopes = await stackFrame.getScopes();
|
||||
const toExpand = scopes.find(s => !s.expensive);
|
||||
if (toExpand && (scopes.every(s => this.tree.isCollapsed(s)) || !this.autoExpandedScopes.has(toExpand.getId()))) {
|
||||
this.autoExpandedScopes.add(toExpand.getId());
|
||||
await this.tree.expand(toExpand);
|
||||
}
|
||||
}, 400);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ export class VariablesView extends ViewPane {
|
||||
dom.addClass(container, 'debug-variables');
|
||||
const treeContainer = renderViewTree(container);
|
||||
|
||||
this.tree = <WorkbenchAsyncDataTree<IViewModel | IExpression | IScope, IExpression | IScope, FuzzyScore>>this.instantiationService.createInstance(WorkbenchAsyncDataTree, 'VariablesView', treeContainer, new VariablesDelegate(),
|
||||
this.tree = <WorkbenchAsyncDataTree<IStackFrame | null, IExpression | IScope, FuzzyScore>>this.instantiationService.createInstance(WorkbenchAsyncDataTree, 'VariablesView', treeContainer, new VariablesDelegate(),
|
||||
[this.instantiationService.createInstance(VariablesRenderer), new ScopesRenderer(), new ScopeErrorRenderer()],
|
||||
new VariablesDataSource(), {
|
||||
accessibilityProvider: new VariablesAccessibilityProvider(),
|
||||
@@ -110,12 +110,10 @@ export class VariablesView extends ViewPane {
|
||||
}
|
||||
});
|
||||
|
||||
this.tree.setInput(this.debugService.getViewModel());
|
||||
this.tree.setInput(withUndefinedAsNull(this.debugService.getViewModel().focusedStackFrame));
|
||||
|
||||
CONTEXT_VARIABLES_FOCUSED.bindTo(this.tree.contextKeyService);
|
||||
|
||||
this.tree.updateChildren();
|
||||
|
||||
this._register(this.debugService.getViewModel().onDidFocusStackFrame(sf => {
|
||||
if (!this.isBodyVisible()) {
|
||||
this.needsRefresh = true;
|
||||
@@ -143,11 +141,24 @@ export class VariablesView extends ViewPane {
|
||||
this.onFocusStackFrameScheduler.schedule();
|
||||
}
|
||||
}));
|
||||
let horizontalScrolling: boolean | undefined;
|
||||
this._register(this.debugService.getViewModel().onDidSelectExpression(e => {
|
||||
if (e instanceof Variable) {
|
||||
horizontalScrolling = this.tree.options.horizontalScrolling;
|
||||
if (horizontalScrolling) {
|
||||
this.tree.updateOptions({ horizontalScrolling: false });
|
||||
}
|
||||
|
||||
this.tree.rerender(e);
|
||||
} else if (!e && horizontalScrolling !== undefined) {
|
||||
this.tree.updateOptions({ horizontalScrolling: horizontalScrolling });
|
||||
horizontalScrolling = undefined;
|
||||
}
|
||||
}));
|
||||
this._register(this.debugService.onDidEndSession(() => {
|
||||
this.savedViewState.clear();
|
||||
this.autoExpandedScopes.clear();
|
||||
}));
|
||||
}
|
||||
|
||||
getActions(): IAction[] {
|
||||
@@ -213,24 +224,26 @@ export class VariablesView extends ViewPane {
|
||||
}
|
||||
}
|
||||
|
||||
function isViewModel(obj: any): obj is IViewModel {
|
||||
return typeof obj.getSelectedExpression === 'function';
|
||||
function isStackFrame(obj: any): obj is IStackFrame {
|
||||
return obj instanceof StackFrame;
|
||||
}
|
||||
|
||||
export class VariablesDataSource implements IAsyncDataSource<IViewModel, IExpression | IScope> {
|
||||
export class VariablesDataSource implements IAsyncDataSource<IStackFrame | null, IExpression | IScope> {
|
||||
|
||||
hasChildren(element: IViewModel | IExpression | IScope): boolean {
|
||||
if (isViewModel(element)) {
|
||||
hasChildren(element: IStackFrame | null | IExpression | IScope): boolean {
|
||||
if (!element) {
|
||||
return false;
|
||||
}
|
||||
if (isStackFrame(element)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return element.hasChildren;
|
||||
}
|
||||
|
||||
getChildren(element: IViewModel | IExpression | IScope): Promise<(IExpression | IScope)[]> {
|
||||
if (isViewModel(element)) {
|
||||
const stackFrame = element.focusedStackFrame;
|
||||
return stackFrame ? stackFrame.getScopes() : Promise.resolve([]);
|
||||
getChildren(element: IStackFrame | IExpression | IScope): Promise<(IExpression | IScope)[]> {
|
||||
if (isStackFrame(element)) {
|
||||
return element.getScopes();
|
||||
}
|
||||
|
||||
return element.getChildren();
|
||||
|
||||
Reference in New Issue
Block a user