Skip to content

Commit 8b0c5ad

Browse files
authored
Merge pull request microsoft#196709 from microsoft/aiday/cancelScheduler
Cancelling the scheduler on model change and model content change
2 parents 9f627c2 + 33b2e4a commit 8b0c5ad

File tree

1 file changed

+12
-6
lines changed
  • src/vs/editor/contrib/hover/browser

1 file changed

+12
-6
lines changed

src/vs/editor/contrib/hover/browser/hover.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,13 @@ export class ModesHoverController extends Disposable implements IEditorContribut
8383
this._hookEvents();
8484
}
8585
}));
86-
this._register(this._editor.onMouseLeave(() => {
87-
this._mouseMoveEvent = undefined;
88-
this._reactToEditorMouseMoveRunner.cancel();
89-
}));
9086
}
9187

9288
private _hookEvents(): void {
93-
const hideWidgetsEventHandler = () => this._hideWidgets();
89+
const hideWidgetsCancelSchedulerEventHandler = () => {
90+
this._cancelScheduler();
91+
this._hideWidgets();
92+
};
9493

9594
const hoverOpts = this._editor.getOption(EditorOption.hover);
9695
this._isHoverEnabled = hoverOpts.enabled;
@@ -107,10 +106,16 @@ export class ModesHoverController extends Disposable implements IEditorContribut
107106
}
108107

109108
this._toUnhook.add(this._editor.onMouseLeave((e) => this._onEditorMouseLeave(e)));
110-
this._toUnhook.add(this._editor.onDidChangeModel(hideWidgetsEventHandler));
109+
this._toUnhook.add(this._editor.onDidChangeModel(hideWidgetsCancelSchedulerEventHandler));
110+
this._toUnhook.add(this._editor.onDidChangeModelContent(hideWidgetsCancelSchedulerEventHandler));
111111
this._toUnhook.add(this._editor.onDidScrollChange((e: IScrollEvent) => this._onEditorScrollChanged(e)));
112112
}
113113

114+
private _cancelScheduler() {
115+
this._mouseMoveEvent = undefined;
116+
this._reactToEditorMouseMoveRunner.cancel();
117+
}
118+
114119
private _unhookEvents(): void {
115120
this._toUnhook.clear();
116121
}
@@ -150,6 +155,7 @@ export class ModesHoverController extends Disposable implements IEditorContribut
150155
}
151156

152157
private _onEditorMouseLeave(mouseEvent: IPartialEditorMouseEvent): void {
158+
this._cancelScheduler();
153159
const targetEm = (mouseEvent.event.browserEvent.relatedTarget) as HTMLElement;
154160
if (this._contentWidget?.widget.isResizing || this._contentWidget?.containsNode(targetEm)) {
155161
// When the content widget is resizing

0 commit comments

Comments
 (0)