adding a setting in order to be able to control the hiding timeout delay

This commit is contained in:
Aiday Marlen Kyzy
2023-08-18 17:06:34 +02:00
parent c61dbc1a71
commit a9e67cddfe
3 changed files with 21 additions and 1 deletions
@@ -2031,6 +2031,11 @@ export interface IEditorHoverOptions {
* Defaults to true.
*/
sticky?: boolean;
/**
* Controls how long the hover is visible after you hovered out of it.
* Require sticky setting to be true.
*/
hidingTimeout?: number;
/**
* Should the hover be shown above the line if possible?
* Defaults to false.
@@ -2049,6 +2054,7 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, IEditorHoverOptio
const defaults: EditorHoverOptions = {
enabled: true,
delay: 300,
hidingTimeout: 750,
sticky: true,
above: true,
};
@@ -2072,6 +2078,12 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, IEditorHoverOptio
default: defaults.sticky,
description: nls.localize('hover.sticky', "Controls whether the hover should remain visible when mouse is moved over it.")
},
'editor.hover.hidingTimeout': {
type: 'integer',
minimum: 0,
default: defaults.hidingTimeout,
description: nls.localize('hover.hidingTimeout', "Controls how long the hover should remain visible after the mouse is hovered out of it in milliseconds. Requires `editor.hover.sticky` to be enabled.")
},
'editor.hover.above': {
type: 'boolean',
default: defaults.above,
@@ -2090,6 +2102,7 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, IEditorHoverOptio
enabled: boolean(input.enabled, this.defaultValue.enabled),
delay: EditorIntOption.clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
sticky: boolean(input.sticky, this.defaultValue.sticky),
hidingTimeout: EditorIntOption.clampedInt(input.hidingTimeout, this.defaultValue.hidingTimeout, 0, 600000),
above: boolean(input.above, this.defaultValue.above),
};
}
+3 -1
View File
@@ -54,6 +54,7 @@ export class ModesHoverController implements IEditorContribution {
private _hoverClicked: boolean;
private _isHoverEnabled!: boolean;
private _isHoverSticky!: boolean;
private _hidingTimeoutDelay!: number;
private _hoverActivatedByColorDecoratorClick: boolean = false;
private _mouseWasOverWidget: boolean = false;
private _hideWidgetsTimeout: NodeJS.Timeout | undefined;
@@ -89,6 +90,7 @@ export class ModesHoverController implements IEditorContribution {
const hoverOpts = this._editor.getOption(EditorOption.hover);
this._isHoverEnabled = hoverOpts.enabled;
this._isHoverSticky = hoverOpts.sticky;
this._hidingTimeoutDelay = hoverOpts.hidingTimeout;
if (this._isHoverEnabled) {
this._toUnhook.add(this._editor.onMouseDown((e: IEditorMouseEvent) => this._onEditorMouseDown(e)));
this._toUnhook.add(this._editor.onMouseUp((e: IEditorMouseEvent) => this._onEditorMouseUp(e)));
@@ -255,7 +257,7 @@ export class ModesHoverController implements IEditorContribution {
this._hideWidgetsTimeout = setTimeout(() => {
this._hideWidgets();
this._hideWidgetsTimeout = undefined;
}, 1000);
}, this._hidingTimeoutDelay);
this._mouseWasOverWidget = false;
} else {
this._hideWidgets();
+5
View File
@@ -4168,6 +4168,11 @@ declare namespace monaco.editor {
* Defaults to true.
*/
sticky?: boolean;
/**
* Controls how long the hover is visible after you hovered out of it.
* Require sticky setting to be true.
*/
hidingTimeout?: number;
/**
* Should the hover be shown above the line if possible?
* Defaults to false.