From b0c4753cd7fa23f9663fa5d3a2d665bb8a303ed2 Mon Sep 17 00:00:00 2001 From: Aiday Marlen Kyzy Date: Thu, 20 Jul 2023 17:18:54 +0200 Subject: [PATCH] cleaning the code --- src/vs/editor/contrib/hover/browser/contentHover.ts | 13 +++++++------ .../contrib/hover/browser/resizableContentWidget.ts | 3 --- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/vs/editor/contrib/hover/browser/contentHover.ts b/src/vs/editor/contrib/hover/browser/contentHover.ts index 8df02583acc..5a7d68dcd2d 100644 --- a/src/vs/editor/contrib/hover/browser/contentHover.ts +++ b/src/vs/editor/contrib/hover/browser/contentHover.ts @@ -471,6 +471,7 @@ export class ContentHoverWidget extends ResizableContentWidget { private static _lastDimensions: dom.Dimension = new dom.Dimension(0, 0); private _visibleData: ContentHoverVisibleData | undefined; + private _position: Position | undefined; private _positionPreference: ContentWidgetPositionPreference | undefined; private readonly _hover: HoverWidget = this._register(new HoverWidget()); @@ -726,17 +727,13 @@ export class ContentHoverWidget extends ResizableContentWidget { } public showAt(node: DocumentFragment, hoverData: ContentHoverVisibleData): void { - - console.log('inside of showAt'); - if (!this._editor || !this._editor.hasModel()) { return; } this._render(node, hoverData); const widgetHeight = dom.getTotalHeight(this._hover.containerDomNode); - const widgetPosition = hoverData.showAtPosition; - this._positionPreference = this._findPositionPreference(widgetHeight, widgetPosition) ?? ContentWidgetPositionPreference.ABOVE; - console.log('this._positionPreference : ', this._positionPreference); + this._position = hoverData.showAtPosition; + this._positionPreference = this._findPositionPreference(widgetHeight, this._position) ?? ContentWidgetPositionPreference.ABOVE; // See https://github.com/microsoft/vscode/issues/140339 // TODO: Doing a second layout of the hover after force rendering the editor @@ -795,6 +792,10 @@ export class ContentHoverWidget extends ResizableContentWidget { this._adjustContentsBottomPadding(); this._adjustHoverHeightForScrollbar(height); } + if (this._position) { + const widgetHeight = dom.getTotalHeight(this._hover.containerDomNode); + this._positionPreference = this._findPositionPreference(widgetHeight, this._position); + } this._layoutContentWidget(); } diff --git a/src/vs/editor/contrib/hover/browser/resizableContentWidget.ts b/src/vs/editor/contrib/hover/browser/resizableContentWidget.ts index 89f3f5e3fd8..0243d9e88bf 100644 --- a/src/vs/editor/contrib/hover/browser/resizableContentWidget.ts +++ b/src/vs/editor/contrib/hover/browser/resizableContentWidget.ts @@ -86,11 +86,8 @@ export abstract class ResizableContentWidget extends Disposable implements ICont protected _findPositionPreference(widgetHeight: number, showAtPosition: IPosition): ContentWidgetPositionPreference | undefined { const maxHeightBelow = Math.min(this._availableVerticalSpaceBelow(showAtPosition) ?? Infinity, widgetHeight); const maxHeightAbove = Math.min(this._availableVerticalSpaceAbove(showAtPosition) ?? Infinity, widgetHeight); - console.log('maxHeightBelow : ', maxHeightBelow); - console.log('maxHeightAbove : ', maxHeightAbove); const maxHeight = Math.min(Math.max(maxHeightAbove, maxHeightBelow), widgetHeight); const height = Math.min(widgetHeight, maxHeight); - console.log('height : ', height); let renderingAbove: ContentWidgetPositionPreference; if (this._editor.getOption(EditorOption.hover).above) { renderingAbove = height <= maxHeightAbove ? ContentWidgetPositionPreference.ABOVE : ContentWidgetPositionPreference.BELOW;