Skip to content

Commit b595dd8

Browse files
committed
renaming the variables
1 parent 3ab9cbc commit b595dd8

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

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

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export class ContentHoverController extends Disposable {
294294
}));
295295
}
296296

297-
this._widget.showAt(fragment, new ContentHoverData(
297+
this._widget.showAt(fragment, new HoverData(
298298
colorPicker,
299299
showAtPosition,
300300
showAtSecondaryPosition,
@@ -428,7 +428,7 @@ class FilteredHoverResult extends HoverResult {
428428
}
429429
}
430430

431-
class ContentHoverData {
431+
class HoverData {
432432

433433
public closestMouseDistance: number | undefined = undefined;
434434

@@ -455,19 +455,19 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
455455
public static ID = 'editor.contrib.resizableContentHoverWidget';
456456

457457
private _disposableStore = new DisposableStore();
458-
private _visibleData: ContentHoverData | undefined;
459-
private _renderingAbove: ContentWidgetPositionPreference | undefined;
458+
private _hoverData: HoverData | undefined;
459+
private _positionPreference: ContentWidgetPositionPreference | undefined;
460460

461461
private readonly _hoverWidget: HoverWidget = this._disposableStore.add(new HoverWidget());
462462
private readonly _hoverVisibleKey: IContextKey<boolean>;
463463
private readonly _hoverFocusedKey: IContextKey<boolean>;
464464

465465
public get isColorPickerVisible(): boolean {
466-
return Boolean(this._visibleData?.colorPicker);
466+
return Boolean(this._hoverData?.colorPicker);
467467
}
468468

469469
public get isVisibleFromKeyboard(): boolean {
470-
return (this._visibleData?.source === HoverStartSource.Keyboard);
470+
return (this._hoverData?.source === HoverStartSource.Keyboard);
471471
}
472472

473473
public get isVisible(): boolean {
@@ -498,13 +498,13 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
498498
this._disposableStore.add(focusTracker.onDidBlur(() => {
499499
this._hoverFocusedKey.set(false);
500500
}));
501-
this._setVisibleData(undefined);
501+
this._setHoverData(undefined);
502502
this._layout();
503503
}
504504

505505
public override dispose(): void {
506506
super.dispose();
507-
this._visibleData?.disposables.dispose();
507+
this._hoverData?.disposables.dispose();
508508
this._disposableStore.dispose();
509509
this._editor.removeContentWidget(this);
510510
}
@@ -563,17 +563,17 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
563563
const width = size.width - 2 * SASH_WIDTH_MINUS_BORDER;
564564
const height = size.height - 2 * SASH_WIDTH_MINUS_BORDER;
565565
this._setHoverWidgetDimensions(width, height);
566-
// measure if has horizontal scorllbar after setting the dimensions
566+
// measure if widget has horizontal scrollbar after setting the dimensions
567567
if (this._hasHorizontalScrollbar()) {
568568
this._adjustContentsBottomPadding();
569569
this._setContentsDomNodeDimensions(width, height - SCROLLBAR_WIDTH);
570570
}
571571
}
572572

573573
private _setResizableNodeMaxDimensions() {
574-
const maxRenderingWidth = this._findMaximumRenderingWidth();
575-
const maxRenderingHeight = this._findMaximumRenderingHeight();
576-
this._resizableNode.maxSize = new dom.Dimension(maxRenderingWidth ?? Infinity, maxRenderingHeight ?? Infinity);
574+
const maxRenderingWidth = this._findMaximumRenderingWidth() ?? Infinity;
575+
const maxRenderingHeight = this._findMaximumRenderingHeight() ?? Infinity;
576+
this._resizableNode.maxSize = new dom.Dimension(maxRenderingWidth, maxRenderingHeight);
577577
}
578578

579579
override _resize(size: dom.Dimension) {
@@ -584,11 +584,11 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
584584
}
585585

586586
private _findAvailableSpaceVertically(): number | undefined {
587-
if (!this._visibleData?.showAtPosition) {
587+
const position = this._hoverData?.showAtPosition;
588+
if (!position) {
588589
return;
589590
}
590-
const position = this._visibleData.showAtPosition;
591-
return this._renderingAbove === ContentWidgetPositionPreference.ABOVE ? this._availableVerticalSpaceAbove(position) : this._availableVerticalSpaceBelow(position);
591+
return this._positionPreference === ContentWidgetPositionPreference.ABOVE ? this._availableVerticalSpaceAbove(position) : this._availableVerticalSpaceBelow(position);
592592
}
593593

594594
private _findAvailableSpaceHorizontally(): number | undefined {
@@ -621,38 +621,38 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
621621
}
622622

623623
public isMouseGettingCloser(posx: number, posy: number): boolean {
624-
if (!this._visibleData) {
624+
if (!this._hoverData) {
625625
return false;
626626
}
627-
if (typeof this._visibleData.initialMousePosX === 'undefined' || typeof this._visibleData.initialMousePosY === 'undefined') {
628-
this._visibleData.initialMousePosX = posx;
629-
this._visibleData.initialMousePosY = posy;
627+
if (typeof this._hoverData.initialMousePosX === 'undefined' || typeof this._hoverData.initialMousePosY === 'undefined') {
628+
this._hoverData.initialMousePosX = posx;
629+
this._hoverData.initialMousePosY = posy;
630630
return false;
631631
}
632632

633633
const widgetRect = dom.getDomNodePagePosition(this.getDomNode());
634-
if (typeof this._visibleData.closestMouseDistance === 'undefined') {
635-
this._visibleData.closestMouseDistance = computeDistanceFromPointToRectangle(this._visibleData.initialMousePosX, this._visibleData.initialMousePosY, widgetRect.left, widgetRect.top, widgetRect.width, widgetRect.height);
634+
if (typeof this._hoverData.closestMouseDistance === 'undefined') {
635+
this._hoverData.closestMouseDistance = computeDistanceFromPointToRectangle(this._hoverData.initialMousePosX, this._hoverData.initialMousePosY, widgetRect.left, widgetRect.top, widgetRect.width, widgetRect.height);
636636
}
637637
const distance = computeDistanceFromPointToRectangle(posx, posy, widgetRect.left, widgetRect.top, widgetRect.width, widgetRect.height);
638-
if (distance > this._visibleData.closestMouseDistance + 4 /* tolerance of 4 pixels */) {
638+
if (distance > this._hoverData.closestMouseDistance + 4 /* tolerance of 4 pixels */) {
639639
// The mouse is getting farther away
640640
return false;
641641
}
642-
this._visibleData.closestMouseDistance = Math.min(this._visibleData.closestMouseDistance, distance);
642+
this._hoverData.closestMouseDistance = Math.min(this._hoverData.closestMouseDistance, distance);
643643
return true;
644644
}
645645

646646
private _setWidgetPosition(position: Position | undefined) {
647647
this._position = position;
648648
}
649649

650-
private _setVisibleData(visibleData: ContentHoverData | undefined): void {
651-
this._setWidgetPosition(visibleData?.showAtPosition);
652-
this._visibleData?.disposables.dispose();
653-
this._visibleData = visibleData;
654-
this._hoverVisibleKey.set(!!visibleData);
655-
this._hoverWidget.containerDomNode.classList.toggle('hidden', !visibleData);
650+
private _setHoverData(hoverData: HoverData | undefined): void {
651+
this._setWidgetPosition(hoverData?.showAtPosition);
652+
this._hoverData?.disposables.dispose();
653+
this._hoverData = hoverData;
654+
this._hoverVisibleKey.set(!!hoverData);
655+
this._hoverWidget.containerDomNode.classList.toggle('hidden', !hoverData);
656656
}
657657

658658
private _layout(): void {
@@ -694,63 +694,61 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
694694
this._setContentsDomNodeMaxDimensions(width, height);
695695
}
696696

697-
private _render(node: DocumentFragment, visibleData: ContentHoverData) {
697+
private _render(node: DocumentFragment, hoverData: HoverData) {
698698
if (!this._hoverVisibleKey.get()) {
699699
this._editor.addContentWidget(this);
700700
}
701-
this._setVisibleData(visibleData);
701+
this._setHoverData(hoverData);
702702
this._updateFont();
703703
this._updateContent(node);
704704
this._updateContentsDomNodeMaxDimensions();
705-
if (!this.findPersistedSize()) {
706-
this.onContentsChanged();
707-
// Simply force a synchronous render on the editor
708-
// such that the widget does not really render with left = '0px'
709-
this._editor.render();
710-
}
705+
this.onContentsChanged();
706+
// Simply force a synchronous render on the editor
707+
// such that the widget does not really render with left = '0px'
708+
this._editor.render();
711709
}
712710

713-
private _setContentPosition(visibleData: ContentHoverData, preference?: ContentWidgetPositionPreference) {
711+
private _setContentPosition(hoverData: HoverData, preference?: ContentWidgetPositionPreference) {
714712
this._contentPosition = {
715-
position: visibleData.showAtPosition,
716-
secondaryPosition: visibleData.showAtSecondaryPosition,
717-
positionAffinity: visibleData.isBeforeContent ? PositionAffinity.LeftOfInjectedText : undefined,
713+
position: hoverData.showAtPosition,
714+
secondaryPosition: hoverData.showAtSecondaryPosition,
715+
positionAffinity: hoverData.isBeforeContent ? PositionAffinity.LeftOfInjectedText : undefined,
718716
preference: [preference ?? ContentWidgetPositionPreference.ABOVE]
719717
};
720718
}
721719

722-
public showAt(node: DocumentFragment, visibleData: ContentHoverData): void {
720+
public showAt(node: DocumentFragment, hoverData: HoverData): void {
723721
if (!this._editor || !this._editor.hasModel()) {
724722
return;
725723
}
726-
this._setContentPosition(visibleData);
727-
this._render(node, visibleData);
724+
this._setContentPosition(hoverData);
725+
this._render(node, hoverData);
728726
const widgetHeight = this._getWidgetHeight();
729-
const widgetPosition = visibleData.showAtPosition;
730-
this._renderingAbove = this._findRenderingPreference(widgetHeight, widgetPosition) ?? ContentWidgetPositionPreference.ABOVE;
731-
this._setContentPosition(visibleData, this._renderingAbove);
727+
const widgetPosition = hoverData.showAtPosition;
728+
this._positionPreference = this._findRenderingPreference(widgetHeight, widgetPosition) ?? ContentWidgetPositionPreference.ABOVE;
729+
this._setContentPosition(hoverData, this._positionPreference);
732730

733731
// See https://github.com/microsoft/vscode/issues/140339
734732
// TODO: Doing a second layout of the hover after force rendering the editor
735733
this.onContentsChanged();
736-
if (visibleData.stoleFocus) {
734+
if (hoverData.stoleFocus) {
737735
this._hoverWidget.containerDomNode.focus();
738736
}
739-
visibleData.colorPicker?.layout();
737+
hoverData.colorPicker?.layout();
740738
}
741739

742740
public hide(): void {
741+
if (!this._hoverData) {
742+
return;
743+
}
744+
this._setHoverData(undefined);
743745
this._resizableNode.maxSize = new dom.Dimension(Infinity, Infinity);
744746
this._resizableNode.clearSashHoverState();
745747
this._editor.removeContentWidget(this);
746-
if (this._visibleData) {
747-
const stoleFocus = this._visibleData.stoleFocus;
748-
this._setVisibleData(undefined);
749-
this._hoverFocusedKey.set(false);
750-
this._editor.layoutContentWidget(this);
751-
if (stoleFocus) {
752-
this._editor.focus();
753-
}
748+
this._hoverFocusedKey.set(false);
749+
this._editor.layoutContentWidget(this);
750+
if (this._hoverData.stoleFocus) {
751+
this._editor.focus();
754752
}
755753
}
756754

@@ -760,8 +758,9 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
760758
const persistedSize = this.findPersistedSize();
761759
// Suppose a persisted size is defined
762760
if (persistedSize) {
763-
width = Math.min(this._findAvailableSpaceHorizontally() ?? Infinity, persistedSize.width - 2 * SASH_WIDTH_MINUS_BORDER);
764-
height = Math.min(this._findAvailableSpaceVertically() ?? Infinity, persistedSize.height - 2 * SASH_WIDTH_MINUS_BORDER);
761+
const totalBorderWidth = 2 * SASH_WIDTH_MINUS_BORDER;
762+
width = Math.min(this._findAvailableSpaceHorizontally() ?? Infinity, persistedSize.width - totalBorderWidth);
763+
height = Math.min(this._findAvailableSpaceVertically() ?? Infinity, persistedSize.height - totalBorderWidth);
765764
} else {
766765
// Added because otherwise the initial size of the hover content is smaller than should be
767766
const layoutInfo = this._editor.getLayoutInfo();
@@ -791,7 +790,8 @@ export class ResizableHoverWidget extends MultiplePersistedSizeResizableContentW
791790
const containerDomNode = this._hoverWidget.containerDomNode;
792791
const clientHeight = containerDomNode.clientHeight;
793792
const clientWidth = containerDomNode.clientWidth;
794-
this._resizableNode.layout(clientHeight + 2 * SASH_WIDTH_MINUS_BORDER, clientWidth + 2 * SASH_WIDTH_MINUS_BORDER);
793+
const totalBorderWidth = 2 * SASH_WIDTH_MINUS_BORDER;
794+
this._resizableNode.layout(clientHeight + totalBorderWidth, clientWidth + totalBorderWidth);
795795
this._setContainerAbsolutePosition(SASH_WIDTH_MINUS_BORDER - 1, SASH_WIDTH_MINUS_BORDER - 1);
796796
if (this._hasHorizontalScrollbar()) {
797797
this._adjustContentsBottomPadding();

0 commit comments

Comments
 (0)