Fixes #146486: Add a eager pointerup listener which shouldn't miss any events

This commit is contained in:
Alex Dima 2022-04-06 00:36:58 +02:00
parent b4b7380576
commit ddf70921cd
No known key found for this signature in database
GPG key ID: 39563C1504FDD0C9

View file

@ -115,6 +115,14 @@ export class MouseHandler extends ViewEventHandler {
mousePointerId = pointerId;
}
}));
// The `pointerup` listener registered by `GlobalEditorPointerMoveMonitor` does not get invoked 100% of the times.
// I speculate that this is because the `pointerup` listener is only registered during the `mousedown` event, and perhaps
// the `pointerup` event is already queued for dispatching, which makes it that the new listener doesn't get fired.
// See https://github.com/microsoft/vscode/issues/146486 for repro steps.
// To compensate for that, we simply register here a `pointerup` listener and just communicate it.
this._register(dom.addDisposableListener(this.viewHelper.viewDomNode, dom.EventType.POINTER_UP, (e: PointerEvent) => {
this._mouseDownOperation.onPointerUp();
}));
this._register(mouseEvents.onMouseDown(this.viewHelper.viewDomNode, (e) => this._onMouseDown(e, mousePointerId)));
const onMouseWheel = (browserEvent: IMouseWheelEvent) => {
@ -443,6 +451,10 @@ class MouseDownOperation extends Disposable {
this._mouseMoveMonitor.stopMonitoring();
}
public onPointerUp(): void {
this._mouseMoveMonitor.stopMonitoring();
}
public onScrollChanged(): void {
if (!this._isActive) {
return;