diff --git a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts index 4e39c57dd0fd0996ebfc66270b021f3b64e18feb..7cfc9d730823a9edf5fff44d3e9fa5ecf68c1060 100644 --- a/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts +++ b/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts @@ -355,7 +355,7 @@ export class DebugEditorContribution implements IDebugEditorContribution { } private hideHoverWidget(): void { - if (!this.hideHoverScheduler.isScheduled() && this.hoverWidget.isVisible()) { + if (!this.hideHoverScheduler.isScheduled() && this.hoverWidget.willBeVisible()) { this.hideHoverScheduler.schedule(); } this.showHoverScheduler.cancel(); diff --git a/src/vs/workbench/contrib/debug/browser/debugHover.ts b/src/vs/workbench/contrib/debug/browser/debugHover.ts index 4e877402dcbc61c3642aef2ca6048a90cbbcd534..be2583fb81d3eba896fb9a497dc6d9eecbd69ce6 100644 --- a/src/vs/workbench/contrib/debug/browser/debugHover.ts +++ b/src/vs/workbench/contrib/debug/browser/debugHover.ts @@ -31,7 +31,7 @@ import { coalesce } from 'vs/base/common/arrays'; import { IAsyncDataSource } from 'vs/base/browser/ui/tree/tree'; import { VariablesRenderer } from 'vs/workbench/contrib/debug/browser/variablesView'; import { EvaluatableExpressionProviderRegistry } from 'vs/editor/common/modes'; -import { CancellationToken } from 'vs/base/common/cancellation'; +import { CancellationTokenSource } from 'vs/base/common/cancellation'; const $ = dom.$; @@ -70,6 +70,7 @@ export class DebugHoverWidget implements IContentWidget { allowEditorOverflow = true; private _isVisible: boolean; + private showCancellationSource?: CancellationTokenSource; private domNode!: HTMLElement; private tree!: AsyncDataTree; private showAtPosition: Position | null; @@ -161,13 +162,17 @@ export class DebugHoverWidget implements IContentWidget { } isHovered(): boolean { - return this.domNode.matches(':hover'); + return !!this.domNode?.matches(':hover'); } isVisible(): boolean { return this._isVisible; } + willBeVisible(): boolean { + return !!this.showCancellationSource; + } + getId(): string { return DebugHoverWidget.ID; } @@ -177,6 +182,8 @@ export class DebugHoverWidget implements IContentWidget { } async showAt(range: Range, focus: boolean): Promise { + this.showCancellationSource?.cancel(); + const cancellationSource = this.showCancellationSource = new CancellationTokenSource(); const session = this.debugService.getViewModel().focusedSession; if (!session || !this.editor.hasModel()) { @@ -193,7 +200,7 @@ export class DebugHoverWidget implements IContentWidget { const supports = EvaluatableExpressionProviderRegistry.ordered(model); const promises = supports.map(support => { - return Promise.resolve(support.provideEvaluatableExpression(model, pos, CancellationToken.None)).then(expression => { + return Promise.resolve(support.provideEvaluatableExpression(model, pos, cancellationSource.token)).then(expression => { return expression; }, err => { //onUnexpectedExternalError(err); @@ -236,7 +243,7 @@ export class DebugHoverWidget implements IContentWidget { } } - if (!expression || (expression instanceof Expression && !expression.available)) { + if (cancellationSource.token.isCancellationRequested || !expression || (expression instanceof Expression && !expression.available)) { this.hide(); return; } @@ -315,6 +322,11 @@ export class DebugHoverWidget implements IContentWidget { hide(): void { + if (this.showCancellationSource) { + this.showCancellationSource.cancel(); + this.showCancellationSource = undefined; + } + if (!this._isVisible) { return; }