diff --git a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts index 3b7f7be2ce81806cf439577937cb77db4cf3b9d3..dc4678a2d39af261633919559a27bcd9e8f52ccd 100644 --- a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts +++ b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts @@ -98,7 +98,7 @@ class DebugEditorContribution implements IDebugEditorContribution { this.wordToLineNumbersMap = undefined; this.updateInlineValuesScheduler.schedule(); })); - this.toDispose.push(this.editor.onDidChangeModel(() => { + this.toDispose.push(this.editor.onDidChangeModel(async () => { const stackFrame = this.debugService.getViewModel().focusedStackFrame; const model = this.editor.getModel(); if (model) { @@ -108,7 +108,7 @@ class DebugEditorContribution implements IDebugEditorContribution { this.hideHoverWidget(); this.updateConfigurationWidgetVisibility(); this.wordToLineNumbersMap = undefined; - this.updateInlineValueDecorations(stackFrame); + await this.updateInlineValueDecorations(stackFrame); })); this.toDispose.push(this.editor.onDidScrollChange(() => this.hideHoverWidget)); this.toDispose.push(this.debugService.onDidChangeState((state: State) => { @@ -155,18 +155,18 @@ class DebugEditorContribution implements IDebugEditorContribution { return Promise.resolve(); } - private onFocusStackFrame(sf: IStackFrame | undefined): void { + private async onFocusStackFrame(sf: IStackFrame | undefined): Promise { const model = this.editor.getModel(); if (model) { this._applyHoverConfiguration(model, sf); if (sf && sf.source.uri.toString() === model.uri.toString()) { - this.toggleExceptionWidget(); + await this.toggleExceptionWidget(); } else { this.hideHoverWidget(); } } - this.updateInlineValueDecorations(sf); + await this.updateInlineValueDecorations(sf); } @memoize @@ -261,7 +261,7 @@ class DebugEditorContribution implements IDebugEditorContribution { // end hover business // exception widget - private toggleExceptionWidget(): void { + private async toggleExceptionWidget(): Promise { // Toggles exception widget based on the state of the current editor model and debug stack frame const model = this.editor.getModel(); const focusedSf = this.debugService.getViewModel().focusedStackFrame; @@ -282,11 +282,10 @@ class DebugEditorContribution implements IDebugEditorContribution { if (this.exceptionWidget && !sameUri) { this.closeExceptionWidget(); } else if (sameUri) { - focusedSf.thread.exceptionInfo.then(exceptionInfo => { - if (exceptionInfo && exceptionSf.range.startLineNumber && exceptionSf.range.startColumn) { - this.showExceptionWidget(exceptionInfo, this.debugService.getViewModel().focusedSession, exceptionSf.range.startLineNumber, exceptionSf.range.startColumn); - } - }); + const exceptionInfo = await focusedSf.thread.exceptionInfo; + if (exceptionInfo && exceptionSf.range.startLineNumber && exceptionSf.range.startColumn) { + this.showExceptionWidget(exceptionInfo, this.debugService.getViewModel().focusedSession, exceptionSf.range.startLineNumber, exceptionSf.range.startColumn); + } } } @@ -320,7 +319,7 @@ class DebugEditorContribution implements IDebugEditorContribution { } } - addLaunchConfiguration(): Promise { + async addLaunchConfiguration(): Promise { /* __GDPR__ "debug/addLaunchConfiguration" : {} */ @@ -364,7 +363,8 @@ class DebugEditorContribution implements IDebugEditorContribution { return this.commandService.executeCommand('editor.action.insertLineAfter'); }; - return insertLine(configurationsArrayPosition).then(() => this.commandService.executeCommand('editor.action.triggerSuggest')); + await insertLine(configurationsArrayPosition); + await this.commandService.executeCommand('editor.action.triggerSuggest'); } // Inline Decorations @@ -380,12 +380,12 @@ class DebugEditorContribution implements IDebugEditorContribution { @memoize private get updateInlineValuesScheduler(): RunOnceScheduler { return new RunOnceScheduler( - () => this.updateInlineValueDecorations(this.debugService.getViewModel().focusedStackFrame), + async () => await this.updateInlineValueDecorations(this.debugService.getViewModel().focusedStackFrame), 200 ); } - private updateInlineValueDecorations(stackFrame: IStackFrame | undefined): void { + private async updateInlineValueDecorations(stackFrame: IStackFrame | undefined): Promise { const model = this.editor.getModel(); if (!this.configurationService.getValue('debug').inlineValues || !model || !stackFrame || model.uri.toString() !== stackFrame.source.uri.toString()) { @@ -397,20 +397,20 @@ class DebugEditorContribution implements IDebugEditorContribution { this.removeInlineValuesScheduler.cancel(); - stackFrame.getMostSpecificScopes(stackFrame.range) - // Get all top level children in the scope chain - .then(scopes => Promise.all(scopes.map(scope => scope.getChildren() - .then(children => { - let range = new Range(0, 0, stackFrame.range.startLineNumber, stackFrame.range.startColumn); - if (scope.range) { - range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn); - } + const scopes = await stackFrame.getMostSpecificScopes(stackFrame.range); + // Get all top level children in the scope chain + const decorationsPerScope = await Promise.all(scopes.map(async scope => { + const children = await scope.getChildren(); + let range = new Range(0, 0, stackFrame.range.startLineNumber, stackFrame.range.startColumn); + if (scope.range) { + range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn); + } + + return this.createInlineValueDecorationsInsideRange(children, range, model); + })); - return this.createInlineValueDecorationsInsideRange(children, range, model); - }))).then(decorationsPerScope => { - const allDecorations = decorationsPerScope.reduce((previous, current) => previous.concat(current), []); - this.editor.setDecorations(INLINE_VALUE_DECORATION_KEY, allDecorations); - })); + const allDecorations = decorationsPerScope.reduce((previous, current) => previous.concat(current), []); + this.editor.setDecorations(INLINE_VALUE_DECORATION_KEY, allDecorations); } private createInlineValueDecorationsInsideRange(expressions: ReadonlyArray, range: Range, model: ITextModel): IDecorationOptions[] { diff --git a/src/vs/workbench/contrib/debug/browser/variablesView.ts b/src/vs/workbench/contrib/debug/browser/variablesView.ts index f7fb8d0f9ebfccb73868773f80ab4774068017b5..b13236f43d2f4ff1f158aad3cc8f73d7486809ce 100644 --- a/src/vs/workbench/contrib/debug/browser/variablesView.ts +++ b/src/vs/workbench/contrib/debug/browser/variablesView.ts @@ -25,7 +25,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { Emitter } from 'vs/base/common/event'; import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService'; import { IAsyncDataTreeViewState } from 'vs/base/browser/ui/tree/asyncDataTree'; -import { onUnexpectedError } from 'vs/base/common/errors'; import { FuzzyScore, createMatches } from 'vs/base/common/filters'; import { HighlightedLabel, IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; @@ -57,28 +56,27 @@ export class VariablesView extends ViewletPanel { super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('variablesSection', "Variables Section") }, keybindingService, contextMenuService, configurationService, contextKeyService); // Use scheduler to prevent unnecessary flashing - this.onFocusStackFrameScheduler = new RunOnceScheduler(() => { + this.onFocusStackFrameScheduler = new RunOnceScheduler(async () => { const stackFrame = this.debugService.getViewModel().focusedStackFrame; this.needsRefresh = false; if (stackFrame && this.savedViewState) { - this.tree.setInput(this.debugService.getViewModel(), this.savedViewState).then(null, onUnexpectedError); + 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(); } - this.tree.updateChildren().then(() => { - if (stackFrame) { - stackFrame.getScopes().then(scopes => { - // 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 && !scopes[0].expensive) { - this.tree.expand(scopes[0]).then(undefined, onUnexpectedError); - } - }); + 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 && !scopes[0].expensive) { + this.tree.expand(scopes[0]); } - }, onUnexpectedError); + } + } }, 400); } @@ -96,7 +94,7 @@ export class VariablesView extends ViewletPanel { keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: (e: IExpression | IScope) => e } }); - this.tree.setInput(this.debugService.getViewModel()).then(null, onUnexpectedError); + this.tree.setInput(this.debugService.getViewModel()); CONTEXT_VARIABLES_FOCUSED.bindTo(this.tree.contextKeyService);