From 9e49c5e8e5ba5a2b053499979bcceb09c6252ded Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Mon, 16 Dec 2024 10:55:32 +0100 Subject: [PATCH 1/2] fixing escape does not close hover --- .../hover/browser/contentHoverController.ts | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/vs/editor/contrib/hover/browser/contentHoverController.ts b/src/vs/editor/contrib/hover/browser/contentHoverController.ts index ca0677d32066a..281d19c12bcb3 100644 --- a/src/vs/editor/contrib/hover/browser/contentHoverController.ts +++ b/src/vs/editor/contrib/hover/browser/contentHoverController.ts @@ -83,18 +83,17 @@ export class ContentHoverController extends Disposable implements IEditorContrib sticky: hoverOpts.sticky, hidingDelay: hoverOpts.hidingDelay }; - if (hoverOpts.enabled) { - this._listenersStore.add(this._editor.onMouseDown((e: IEditorMouseEvent) => this._onEditorMouseDown(e))); - this._listenersStore.add(this._editor.onMouseUp(() => this._onEditorMouseUp())); - this._listenersStore.add(this._editor.onMouseMove((e: IEditorMouseEvent) => this._onEditorMouseMove(e))); - this._listenersStore.add(this._editor.onKeyDown((e: IKeyboardEvent) => this._onKeyDown(e))); - this._listenersStore.add(this._editor.onMouseLeave((e) => this._onEditorMouseLeave(e))); - this._listenersStore.add(this._editor.onDidChangeModel(() => this._cancelSchedulerAndHide())); - this._listenersStore.add(this._editor.onDidChangeModelContent(() => this._cancelScheduler())); - this._listenersStore.add(this._editor.onDidScrollChange((e: IScrollEvent) => this._onEditorScrollChanged(e))); - } else { + if (!hoverOpts.enabled) { this._cancelSchedulerAndHide(); } + this._listenersStore.add(this._editor.onMouseDown((e: IEditorMouseEvent) => this._onEditorMouseDown(e))); + this._listenersStore.add(this._editor.onMouseUp(() => this._onEditorMouseUp())); + this._listenersStore.add(this._editor.onMouseMove((e: IEditorMouseEvent) => this._onEditorMouseMove(e))); + this._listenersStore.add(this._editor.onKeyDown((e: IKeyboardEvent) => this._onKeyDown(e))); + this._listenersStore.add(this._editor.onMouseLeave((e) => this._onEditorMouseLeave(e))); + this._listenersStore.add(this._editor.onDidChangeModel(() => this._cancelSchedulerAndHide())); + this._listenersStore.add(this._editor.onDidChangeModelContent(() => this._cancelScheduler())); + this._listenersStore.add(this._editor.onDidScrollChange((e: IScrollEvent) => this._onEditorScrollChanged(e))); } private _unhookListeners(): void { @@ -203,6 +202,10 @@ export class ContentHoverController extends Disposable implements IEditorContrib if (this._contentWidget && (this._contentWidget.isFocused || this._contentWidget.isResizing || this._isMouseDown && this._contentWidget.isColorPickerVisible)) { return false; } + const hiddenAndDisabled = !this._contentWidget?.isVisible && !this._hoverSettings.enabled; + if (hiddenAndDisabled) { + return false; + } const sticky = this._hoverSettings.sticky; if (sticky && this._contentWidget?.isVisibleFromKeyboard) { // Sticky mode is on and the hover has been shown via keyboard From 4b53cd8500da38c2c291ddc36413be4558e0e27c Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Mon, 16 Dec 2024 11:02:42 +0100 Subject: [PATCH 2/2] polish --- .../contrib/hover/browser/contentHoverController.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/vs/editor/contrib/hover/browser/contentHoverController.ts b/src/vs/editor/contrib/hover/browser/contentHoverController.ts index 281d19c12bcb3..3f8e450ec9ed4 100644 --- a/src/vs/editor/contrib/hover/browser/contentHoverController.ts +++ b/src/vs/editor/contrib/hover/browser/contentHoverController.ts @@ -202,10 +202,6 @@ export class ContentHoverController extends Disposable implements IEditorContrib if (this._contentWidget && (this._contentWidget.isFocused || this._contentWidget.isResizing || this._isMouseDown && this._contentWidget.isColorPickerVisible)) { return false; } - const hiddenAndDisabled = !this._contentWidget?.isVisible && !this._hoverSettings.enabled; - if (hiddenAndDisabled) { - return false; - } const sticky = this._hoverSettings.sticky; if (sticky && this._contentWidget?.isVisibleFromKeyboard) { // Sticky mode is on and the hover has been shown via keyboard @@ -232,9 +228,11 @@ export class ContentHoverController extends Disposable implements IEditorContrib if (!mouseEvent) { return; } - const contentWidget: ContentHoverWidgetWrapper = this._getOrCreateContentWidget(); - if (contentWidget.showsOrWillShow(mouseEvent)) { - return; + if (this._hoverSettings.enabled) { + const contentWidget: ContentHoverWidgetWrapper = this._getOrCreateContentWidget(); + if (contentWidget.showsOrWillShow(mouseEvent)) { + return; + } } if (_sticky) { return;