Skip to content

Commit b8672f1

Browse files
authored
Merge pull request microsoft#146860 from microsoft/alex/stable-146486
Add an eager `pointerup` listener which shouldn't miss any events
2 parents b6b76c9 + e12596e commit b8672f1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/vs/editor/browser/controller/mouseHandler.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ export class MouseHandler extends ViewEventHandler {
115115
mousePointerId = pointerId;
116116
}
117117
}));
118+
// The `pointerup` listener registered by `GlobalEditorPointerMoveMonitor` does not get invoked 100% of the times.
119+
// I speculate that this is because the `pointerup` listener is only registered during the `mousedown` event, and perhaps
120+
// the `pointerup` event is already queued for dispatching, which makes it that the new listener doesn't get fired.
121+
// See https://github.com/microsoft/vscode/issues/146486 for repro steps.
122+
// To compensate for that, we simply register here a `pointerup` listener and just communicate it.
123+
this._register(dom.addDisposableListener(this.viewHelper.viewDomNode, dom.EventType.POINTER_UP, (e: PointerEvent) => {
124+
this._mouseDownOperation.onPointerUp();
125+
}));
118126
this._register(mouseEvents.onMouseDown(this.viewHelper.viewDomNode, (e) => this._onMouseDown(e, mousePointerId)));
119127

120128
const onMouseWheel = (browserEvent: IMouseWheelEvent) => {
@@ -443,6 +451,10 @@ class MouseDownOperation extends Disposable {
443451
this._mouseMoveMonitor.stopMonitoring();
444452
}
445453

454+
public onPointerUp(): void {
455+
this._mouseMoveMonitor.stopMonitoring();
456+
}
457+
446458
public onScrollChanged(): void {
447459
if (!this._isActive) {
448460
return;

0 commit comments

Comments
 (0)