Cancel mouse down operation when the editor height changes (#113818)

This commit is contained in:
Alexandru Dima 2021-02-22 17:13:20 +01:00
parent f1d92e7896
commit a0945131a1
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
2 changed files with 21 additions and 0 deletions

View file

@ -71,6 +71,7 @@ export class MouseHandler extends ViewEventHandler {
protected mouseTargetFactory: MouseTargetFactory;
protected readonly _mouseDownOperation: MouseDownOperation;
private lastMouseLeaveTime: number;
private _height: number;
constructor(context: ViewContext, viewController: ViewController, viewHelper: IPointerHandlerHelper) {
super();
@ -89,6 +90,7 @@ export class MouseHandler extends ViewEventHandler {
));
this.lastMouseLeaveTime = -1;
this._height = this._context.configuration.options.get(EditorOption.layoutInfo).height;
const mouseEvents = new EditorMouseEventFactory(this.viewHelper.viewDomNode);
@ -135,6 +137,17 @@ export class MouseHandler extends ViewEventHandler {
}
// --- begin event handlers
public onConfigurationChanged(e: viewEvents.ViewConfigurationChangedEvent): boolean {
if (e.hasChanged(EditorOption.layoutInfo)) {
// layout change
const height = this._context.configuration.options.get(EditorOption.layoutInfo).height;
if (this._height !== height) {
this._height = height;
this._mouseDownOperation.onHeightChanged();
}
}
return false;
}
public onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean {
this._mouseDownOperation.onCursorStateChanged(e);
return false;
@ -401,6 +414,10 @@ class MouseDownOperation extends Disposable {
this._onScrollTimeout.cancel();
}
public onHeightChanged(): void {
this._mouseMoveMonitor.stopMonitoring();
}
public onScrollChanged(): void {
if (!this._isActive) {
return;

View file

@ -210,4 +210,8 @@ export class GlobalEditorMouseMoveMonitor extends Disposable {
onStopCallback(e);
});
}
public stopMonitoring(): void {
this._globalMouseMoveMonitor.stopMonitoring(true);
}
}