未验证 提交 426f82c6 编写于 作者: A Alexandru Dima 提交者: GitHub

Merge pull request #127609 from Timmmm/hover_position

Add setting to control hover position
......@@ -1776,6 +1776,11 @@ export interface IEditorHoverOptions {
* Defaults to true.
*/
sticky?: boolean;
/**
* Should the hover be shown below the line if possible?
* Defaults to false.
*/
below?: boolean;
}
/**
......@@ -1789,7 +1794,8 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOption
const defaults: EditorHoverOptions = {
enabled: true,
delay: 300,
sticky: true
sticky: true,
below: false,
};
super(
EditorOption.hover, 'hover', defaults,
......@@ -1809,6 +1815,11 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOption
default: defaults.sticky,
description: nls.localize('hover.sticky', "Controls whether the hover should remain visible when mouse is moved over it.")
},
'editor.hover.below': {
type: 'boolean',
default: defaults.below,
description: nls.localize('hover.below', "Show hovers below the line instead of above, if there's space.")
},
}
);
}
......@@ -1821,7 +1832,8 @@ class EditorHover extends BaseEditorOption<EditorOption.hover, EditorHoverOption
return {
enabled: boolean(input.enabled, this.defaultValue.enabled),
delay: EditorIntOption.clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
sticky: boolean(input.sticky, this.defaultValue.sticky)
sticky: boolean(input.sticky, this.defaultValue.sticky),
below: boolean(input.below, this.defaultValue.below),
};
}
}
......
......@@ -199,6 +199,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
private _shouldFocus: boolean;
private _colorPicker: ColorPickerWidget | null;
private _renderDisposable: IDisposable | null;
private _preferBelow: boolean;
constructor(
editor: ICodeEditor,
......@@ -250,6 +251,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
this._isChangingDecorations = false;
this._shouldFocus = false;
this._colorPicker = null;
this._preferBelow = this._editor.getOption(EditorOption.hover).below;
this._hoverOperation = new HoverOperation(
this._computer,
......@@ -269,6 +271,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
}));
this._register(editor.onDidChangeConfiguration(() => {
this._hoverOperation.setHoverTime(this._editor.getOption(EditorOption.hover).delay);
this._preferBelow = this._editor.getOption(EditorOption.hover).below;
}));
this._register(TokenizationRegistry.onDidChange(() => {
if (this._isVisible && this._lastAnchor && this._messages.length > 0) {
......@@ -368,10 +371,13 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I
return {
position: this._showAtPosition,
range: this._showAtRange,
preference: [
preference: this._preferBelow ? [
ContentWidgetPositionPreference.BELOW,
ContentWidgetPositionPreference.ABOVE,
ContentWidgetPositionPreference.BELOW
]
] : [
ContentWidgetPositionPreference.ABOVE,
ContentWidgetPositionPreference.BELOW,
],
};
}
return null;
......
......@@ -3510,6 +3510,11 @@ declare namespace monaco.editor {
* Defaults to true.
*/
sticky?: boolean;
/**
* Should the hover be shown below the line if possible?
* Defaults to false.
*/
below?: boolean;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册