未验证 提交 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 { ...@@ -355,7 +355,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
} }
private hideHoverWidget(): void { private hideHoverWidget(): void {
if (!this.hideHoverScheduler.isScheduled() && this.hoverWidget.isVisible()) { if (!this.hideHoverScheduler.isScheduled() && this.hoverWidget.willBeVisible()) {
this.hideHoverScheduler.schedule(); this.hideHoverScheduler.schedule();
} }
this.showHoverScheduler.cancel(); this.showHoverScheduler.cancel();
......
...@@ -31,7 +31,7 @@ import { coalesce } from 'vs/base/common/arrays'; ...@@ -31,7 +31,7 @@ import { coalesce } from 'vs/base/common/arrays';
import { IAsyncDataSource } from 'vs/base/browser/ui/tree/tree'; import { IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
import { VariablesRenderer } from 'vs/workbench/contrib/debug/browser/variablesView'; import { VariablesRenderer } from 'vs/workbench/contrib/debug/browser/variablesView';
import { EvaluatableExpressionProviderRegistry } from 'vs/editor/common/modes'; import { EvaluatableExpressionProviderRegistry } from 'vs/editor/common/modes';
import { CancellationToken } from 'vs/base/common/cancellation'; import { CancellationTokenSource } from 'vs/base/common/cancellation';
const $ = dom.$; const $ = dom.$;
...@@ -70,6 +70,7 @@ export class DebugHoverWidget implements IContentWidget { ...@@ -70,6 +70,7 @@ export class DebugHoverWidget implements IContentWidget {
allowEditorOverflow = true; allowEditorOverflow = true;
private _isVisible: boolean; private _isVisible: boolean;
private showCancellationSource?: CancellationTokenSource;
private domNode!: HTMLElement; private domNode!: HTMLElement;
private tree!: AsyncDataTree<IExpression, IExpression, any>; private tree!: AsyncDataTree<IExpression, IExpression, any>;
private showAtPosition: Position | null; private showAtPosition: Position | null;
...@@ -161,13 +162,17 @@ export class DebugHoverWidget implements IContentWidget { ...@@ -161,13 +162,17 @@ export class DebugHoverWidget implements IContentWidget {
} }
isHovered(): boolean { isHovered(): boolean {
return this.domNode.matches(':hover'); return !!this.domNode?.matches(':hover');
} }
isVisible(): boolean { isVisible(): boolean {
return this._isVisible; return this._isVisible;
} }
willBeVisible(): boolean {
return !!this.showCancellationSource;
}
getId(): string { getId(): string {
return DebugHoverWidget.ID; return DebugHoverWidget.ID;
} }
...@@ -177,6 +182,8 @@ export class DebugHoverWidget implements IContentWidget { ...@@ -177,6 +182,8 @@ export class DebugHoverWidget implements IContentWidget {
} }
async showAt(range: Range, focus: boolean): Promise<void> { async showAt(range: Range, focus: boolean): Promise<void> {
this.showCancellationSource?.cancel();
const cancellationSource = this.showCancellationSource = new CancellationTokenSource();
const session = this.debugService.getViewModel().focusedSession; const session = this.debugService.getViewModel().focusedSession;
if (!session || !this.editor.hasModel()) { if (!session || !this.editor.hasModel()) {
...@@ -193,7 +200,7 @@ export class DebugHoverWidget implements IContentWidget { ...@@ -193,7 +200,7 @@ export class DebugHoverWidget implements IContentWidget {
const supports = EvaluatableExpressionProviderRegistry.ordered(model); const supports = EvaluatableExpressionProviderRegistry.ordered(model);
const promises = supports.map(support => { 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; return expression;
}, err => { }, err => {
//onUnexpectedExternalError(err); //onUnexpectedExternalError(err);
...@@ -236,7 +243,7 @@ export class DebugHoverWidget implements IContentWidget { ...@@ -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(); this.hide();
return; return;
} }
...@@ -315,6 +322,11 @@ export class DebugHoverWidget implements IContentWidget { ...@@ -315,6 +322,11 @@ export class DebugHoverWidget implements IContentWidget {
hide(): void { hide(): void {
if (this.showCancellationSource) {
this.showCancellationSource.cancel();
this.showCancellationSource = undefined;
}
if (!this._isVisible) { if (!this._isVisible) {
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册