Skip to content

Commit 18eb6fd

Browse files
committed
cleaning the code
1 parent d689519 commit 18eb6fd

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/vs/editor/contrib/hover/browser/contentHover.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,9 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
601601
return;
602602
}
603603
let maximumHeight = 3 * SASH_WIDTH_MINUS_BORDER;
604-
for (const hoverPart of this._hoverWidget.contentsDomNode.children) {
604+
Array.from(this._hoverWidget.contentsDomNode.children).forEach((hoverPart) => {
605605
maximumHeight += hoverPart.clientHeight;
606-
}
606+
});
607607
if (this._hasHorizontalScrollbar()) {
608608
maximumHeight += SCROLLBAR_WIDTH;
609609
}
@@ -615,11 +615,9 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
615615
return;
616616
}
617617
const editorBox = dom.getDomNodePagePosition(this._editor.getDomNode());
618-
const widthOfEditor = editorBox.width;
619-
const leftOfEditor = editorBox.left;
620618
const glyphMarginWidth = this._editor.getLayoutInfo().glyphMarginWidth;
621619
const leftOfContainer = this._hoverWidget.containerDomNode.offsetLeft;
622-
return widthOfEditor + leftOfEditor - leftOfContainer - glyphMarginWidth;
620+
return editorBox.width + editorBox.left - leftOfContainer - glyphMarginWidth;
623621
}
624622

625623
public isMouseGettingCloser(posx: number, posy: number): boolean {
@@ -645,18 +643,21 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
645643
return true;
646644
}
647645

646+
private _setWidgetPosition(position: Position | undefined) {
647+
this._position = position;
648+
}
649+
648650
private _setVisibleData(visibleData: ContentHoverData | undefined): void {
649-
this._position = visibleData?.showAtPosition;
651+
this._setWidgetPosition(visibleData?.showAtPosition);
650652
this._visibleData?.disposables.dispose();
651653
this._visibleData = visibleData;
652-
this._hoverVisibleKey.set(!!this._visibleData);
653-
this._hoverWidget.containerDomNode.classList.toggle('hidden', !this._visibleData);
654+
this._hoverVisibleKey.set(!!visibleData);
655+
this._hoverWidget.containerDomNode.classList.toggle('hidden', !visibleData);
654656
}
655657

656658
private _layout(): void {
657659
const height = Math.max(this._editor.getLayoutInfo().height / 4, 250);
658660
const { fontSize, lineHeight } = this._editor.getOption(EditorOption.fontInfo);
659-
660661
const contentsDomNode = this._hoverWidget.contentsDomNode;
661662
contentsDomNode.style.fontSize = `${fontSize}px`;
662663
contentsDomNode.style.lineHeight = `${lineHeight / fontSize}`;
@@ -678,12 +679,7 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
678679
private _getWidgetHeight(): number {
679680
const containerDomNode = this._hoverWidget.containerDomNode;
680681
const persistedSize = this.findPersistedSize();
681-
if (!persistedSize) {
682-
return containerDomNode.clientHeight + 2 * SASH_WIDTH_MINUS_BORDER;
683-
}
684-
else {
685-
return persistedSize.height;
686-
}
682+
return persistedSize ? persistedSize.height : containerDomNode.clientHeight + 2 * SASH_WIDTH_MINUS_BORDER;
687683
}
688684

689685
private _layoutContentWidget(): void {

0 commit comments

Comments
 (0)