未验证 提交 80a9ecff 编写于 作者: C Connor Peet

debug: cancel hover evaluate requests when hovering off dialog

Fixes https://github.com/microsoft/vscode/issues/91457
上级 451c2b61
......@@ -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();
......
......@@ -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<IExpression, IExpression, any>;
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<void> {
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册