提交 ed193fcb 编写于 作者: I isidor

debug: more async await

上级 3bbd6bfd
...@@ -98,7 +98,7 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -98,7 +98,7 @@ class DebugEditorContribution implements IDebugEditorContribution {
this.wordToLineNumbersMap = undefined; this.wordToLineNumbersMap = undefined;
this.updateInlineValuesScheduler.schedule(); this.updateInlineValuesScheduler.schedule();
})); }));
this.toDispose.push(this.editor.onDidChangeModel(() => { this.toDispose.push(this.editor.onDidChangeModel(async () => {
const stackFrame = this.debugService.getViewModel().focusedStackFrame; const stackFrame = this.debugService.getViewModel().focusedStackFrame;
const model = this.editor.getModel(); const model = this.editor.getModel();
if (model) { if (model) {
...@@ -108,7 +108,7 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -108,7 +108,7 @@ class DebugEditorContribution implements IDebugEditorContribution {
this.hideHoverWidget(); this.hideHoverWidget();
this.updateConfigurationWidgetVisibility(); this.updateConfigurationWidgetVisibility();
this.wordToLineNumbersMap = undefined; this.wordToLineNumbersMap = undefined;
this.updateInlineValueDecorations(stackFrame); await this.updateInlineValueDecorations(stackFrame);
})); }));
this.toDispose.push(this.editor.onDidScrollChange(() => this.hideHoverWidget)); this.toDispose.push(this.editor.onDidScrollChange(() => this.hideHoverWidget));
this.toDispose.push(this.debugService.onDidChangeState((state: State) => { this.toDispose.push(this.debugService.onDidChangeState((state: State) => {
...@@ -155,18 +155,18 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -155,18 +155,18 @@ class DebugEditorContribution implements IDebugEditorContribution {
return Promise.resolve(); return Promise.resolve();
} }
private onFocusStackFrame(sf: IStackFrame | undefined): void { private async onFocusStackFrame(sf: IStackFrame | undefined): Promise<void> {
const model = this.editor.getModel(); const model = this.editor.getModel();
if (model) { if (model) {
this._applyHoverConfiguration(model, sf); this._applyHoverConfiguration(model, sf);
if (sf && sf.source.uri.toString() === model.uri.toString()) { if (sf && sf.source.uri.toString() === model.uri.toString()) {
this.toggleExceptionWidget(); await this.toggleExceptionWidget();
} else { } else {
this.hideHoverWidget(); this.hideHoverWidget();
} }
} }
this.updateInlineValueDecorations(sf); await this.updateInlineValueDecorations(sf);
} }
@memoize @memoize
...@@ -261,7 +261,7 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -261,7 +261,7 @@ class DebugEditorContribution implements IDebugEditorContribution {
// end hover business // end hover business
// exception widget // exception widget
private toggleExceptionWidget(): void { private async toggleExceptionWidget(): Promise<void> {
// Toggles exception widget based on the state of the current editor model and debug stack frame // Toggles exception widget based on the state of the current editor model and debug stack frame
const model = this.editor.getModel(); const model = this.editor.getModel();
const focusedSf = this.debugService.getViewModel().focusedStackFrame; const focusedSf = this.debugService.getViewModel().focusedStackFrame;
...@@ -282,11 +282,10 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -282,11 +282,10 @@ class DebugEditorContribution implements IDebugEditorContribution {
if (this.exceptionWidget && !sameUri) { if (this.exceptionWidget && !sameUri) {
this.closeExceptionWidget(); this.closeExceptionWidget();
} else if (sameUri) { } else if (sameUri) {
focusedSf.thread.exceptionInfo.then(exceptionInfo => { const exceptionInfo = await focusedSf.thread.exceptionInfo;
if (exceptionInfo && exceptionSf.range.startLineNumber && exceptionSf.range.startColumn) { if (exceptionInfo && exceptionSf.range.startLineNumber && exceptionSf.range.startColumn) {
this.showExceptionWidget(exceptionInfo, this.debugService.getViewModel().focusedSession, 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 { ...@@ -320,7 +319,7 @@ class DebugEditorContribution implements IDebugEditorContribution {
} }
} }
addLaunchConfiguration(): Promise<any> { async addLaunchConfiguration(): Promise<any> {
/* __GDPR__ /* __GDPR__
"debug/addLaunchConfiguration" : {} "debug/addLaunchConfiguration" : {}
*/ */
...@@ -364,7 +363,8 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -364,7 +363,8 @@ class DebugEditorContribution implements IDebugEditorContribution {
return this.commandService.executeCommand('editor.action.insertLineAfter'); 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 // Inline Decorations
...@@ -380,12 +380,12 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -380,12 +380,12 @@ class DebugEditorContribution implements IDebugEditorContribution {
@memoize @memoize
private get updateInlineValuesScheduler(): RunOnceScheduler { private get updateInlineValuesScheduler(): RunOnceScheduler {
return new RunOnceScheduler( return new RunOnceScheduler(
() => this.updateInlineValueDecorations(this.debugService.getViewModel().focusedStackFrame), async () => await this.updateInlineValueDecorations(this.debugService.getViewModel().focusedStackFrame),
200 200
); );
} }
private updateInlineValueDecorations(stackFrame: IStackFrame | undefined): void { private async updateInlineValueDecorations(stackFrame: IStackFrame | undefined): Promise<void> {
const model = this.editor.getModel(); const model = this.editor.getModel();
if (!this.configurationService.getValue<IDebugConfiguration>('debug').inlineValues || if (!this.configurationService.getValue<IDebugConfiguration>('debug').inlineValues ||
!model || !stackFrame || model.uri.toString() !== stackFrame.source.uri.toString()) { !model || !stackFrame || model.uri.toString() !== stackFrame.source.uri.toString()) {
...@@ -397,20 +397,20 @@ class DebugEditorContribution implements IDebugEditorContribution { ...@@ -397,20 +397,20 @@ class DebugEditorContribution implements IDebugEditorContribution {
this.removeInlineValuesScheduler.cancel(); this.removeInlineValuesScheduler.cancel();
stackFrame.getMostSpecificScopes(stackFrame.range) const scopes = await stackFrame.getMostSpecificScopes(stackFrame.range);
// Get all top level children in the scope chain // Get all top level children in the scope chain
.then(scopes => Promise.all(scopes.map(scope => scope.getChildren() const decorationsPerScope = await Promise.all(scopes.map(async scope => {
.then(children => { const children = await scope.getChildren();
let range = new Range(0, 0, stackFrame.range.startLineNumber, stackFrame.range.startColumn); let range = new Range(0, 0, stackFrame.range.startLineNumber, stackFrame.range.startColumn);
if (scope.range) { if (scope.range) {
range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn); range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn);
} }
return this.createInlineValueDecorationsInsideRange(children, range, model);
}));
return this.createInlineValueDecorationsInsideRange(children, range, model); const allDecorations = decorationsPerScope.reduce((previous, current) => previous.concat(current), []);
}))).then(decorationsPerScope => { 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<IExpression>, range: Range, model: ITextModel): IDecorationOptions[] { private createInlineValueDecorationsInsideRange(expressions: ReadonlyArray<IExpression>, range: Range, model: ITextModel): IDecorationOptions[] {
......
...@@ -25,7 +25,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti ...@@ -25,7 +25,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { Emitter } from 'vs/base/common/event'; import { Emitter } from 'vs/base/common/event';
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService'; import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
import { IAsyncDataTreeViewState } from 'vs/base/browser/ui/tree/asyncDataTree'; 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 { FuzzyScore, createMatches } from 'vs/base/common/filters';
import { HighlightedLabel, IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel'; import { HighlightedLabel, IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
...@@ -57,28 +56,27 @@ export class VariablesView extends ViewletPanel { ...@@ -57,28 +56,27 @@ export class VariablesView extends ViewletPanel {
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('variablesSection', "Variables Section") }, keybindingService, contextMenuService, configurationService, contextKeyService); super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('variablesSection', "Variables Section") }, keybindingService, contextMenuService, configurationService, contextKeyService);
// Use scheduler to prevent unnecessary flashing // Use scheduler to prevent unnecessary flashing
this.onFocusStackFrameScheduler = new RunOnceScheduler(() => { this.onFocusStackFrameScheduler = new RunOnceScheduler(async () => {
const stackFrame = this.debugService.getViewModel().focusedStackFrame; const stackFrame = this.debugService.getViewModel().focusedStackFrame;
this.needsRefresh = false; this.needsRefresh = false;
if (stackFrame && this.savedViewState) { 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; this.savedViewState = undefined;
} else { } else {
if (!stackFrame) { if (!stackFrame) {
// We have no stackFrame, save tree state before it is cleared // We have no stackFrame, save tree state before it is cleared
this.savedViewState = this.tree.getViewState(); this.savedViewState = this.tree.getViewState();
} }
this.tree.updateChildren().then(() => { await this.tree.updateChildren();
if (stackFrame) { if (stackFrame) {
stackFrame.getScopes().then(scopes => { const scopes = await stackFrame.getScopes();
// Expand the first scope if it is not expensive and if there is no expansion state (all are collapsed) // 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) { if (scopes.every(s => this.tree.getNode(s).collapsed) && scopes.length > 0 && !scopes[0].expensive) {
this.tree.expand(scopes[0]).then(undefined, onUnexpectedError); this.tree.expand(scopes[0]);
}
});
} }
}, onUnexpectedError); }
} }
}, 400); }, 400);
} }
...@@ -96,7 +94,7 @@ export class VariablesView extends ViewletPanel { ...@@ -96,7 +94,7 @@ export class VariablesView extends ViewletPanel {
keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: (e: IExpression | IScope) => e } 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); CONTEXT_VARIABLES_FOCUSED.bindTo(this.tree.contextKeyService);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册