Skip to content

Commit 78fffb9

Browse files
committed
Renames
1 parent ba61231 commit 78fffb9

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

src/vs/editor/browser/viewParts/contentWidgets/contentWidgets.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -292,25 +292,25 @@ class Widget {
292292
this._cachedDomNodeOffsetHeight = -1;
293293
}
294294

295-
private _layoutBoxInViewport(topLeft: Coordinate, bottomLeft: Coordinate, width: number, height: number, ctx: RenderingContext): IBoxLayoutResult {
295+
private _layoutBoxInViewport(aboveAnchor: Coordinate, belowAnchor: Coordinate, width: number, height: number, ctx: RenderingContext): IBoxLayoutResult {
296296
// Our visible box is split horizontally by the current line => 2 boxes
297297

298298
// a) the box above the line
299-
const aboveLineTop = topLeft.top;
300-
const heightAboveLine = aboveLineTop;
299+
const aboveLineTop = aboveAnchor.top;
300+
const heightAvailableAboveLine = aboveLineTop;
301301

302302
// b) the box under the line
303-
const underLineTop = bottomLeft.top;
304-
const heightUnderLine = ctx.viewportHeight - underLineTop;
303+
const underLineTop = belowAnchor.top;
304+
const heightAvailableUnderLine = ctx.viewportHeight - underLineTop;
305305

306306
const aboveTop = aboveLineTop - height;
307-
const fitsAbove = (heightAboveLine >= height);
307+
const fitsAbove = (heightAvailableAboveLine >= height);
308308
const belowTop = underLineTop;
309-
const fitsBelow = (heightUnderLine >= height);
309+
const fitsBelow = (heightAvailableUnderLine >= height);
310310

311311
// And its left
312-
let actualAboveLeft = topLeft.left;
313-
let actualBelowLeft = bottomLeft.left;
312+
let actualAboveLeft = aboveAnchor.left;
313+
let actualBelowLeft = belowAnchor.left;
314314
if (actualAboveLeft + width > ctx.scrollLeft + ctx.viewportWidth) {
315315
actualAboveLeft = ctx.scrollLeft + ctx.viewportWidth - width;
316316
}
@@ -357,17 +357,17 @@ class Widget {
357357
return [left, absoluteLeft];
358358
}
359359

360-
private _layoutBoxInPage(topLeft: Coordinate, bottomLeft: Coordinate, width: number, height: number, ctx: RenderingContext): IBoxLayoutResult | null {
361-
const aboveTop = topLeft.top - height;
362-
const belowTop = bottomLeft.top;
360+
private _layoutBoxInPage(aboveAnchor: Coordinate, belowAnchor: Coordinate, width: number, height: number, ctx: RenderingContext): IBoxLayoutResult | null {
361+
const aboveTop = aboveAnchor.top - height;
362+
const belowTop = belowAnchor.top;
363363

364364
const domNodePosition = dom.getDomNodePagePosition(this._viewDomNode.domNode);
365365
const absoluteAboveTop = domNodePosition.top + aboveTop - window.scrollY;
366366
const absoluteBelowTop = domNodePosition.top + belowTop - window.scrollY;
367367

368368
const windowSize = dom.getClientArea(document.body);
369-
const [aboveLeft, absoluteAboveLeft] = this._layoutHorizontalSegmentInPage(windowSize, domNodePosition, topLeft.left - ctx.scrollLeft + this._contentLeft, width);
370-
const [belowLeft, absoluteBelowLeft] = this._layoutHorizontalSegmentInPage(windowSize, domNodePosition, bottomLeft.left - ctx.scrollLeft + this._contentLeft, width);
369+
const [aboveLeft, absoluteAboveLeft] = this._layoutHorizontalSegmentInPage(windowSize, domNodePosition, aboveAnchor.left - ctx.scrollLeft + this._contentLeft, width);
370+
const [belowLeft, absoluteBelowLeft] = this._layoutHorizontalSegmentInPage(windowSize, domNodePosition, belowAnchor.left - ctx.scrollLeft + this._contentLeft, width);
371371

372372
// Leave some clearance to the top/bottom
373373
const TOP_PADDING = 22;
@@ -389,7 +389,7 @@ class Widget {
389389

390390
return {
391391
fitsAbove,
392-
aboveTop: aboveTop,
392+
aboveTop,
393393
aboveLeft,
394394
fitsBelow,
395395
belowTop,
@@ -402,18 +402,17 @@ class Widget {
402402
}
403403

404404
/**
405-
* Compute `this._topLeft`
405+
* Compute the above and below anchors
406406
*/
407-
private _getTopAndBottomLeft(ctx: RenderingContext): [Coordinate | null, Coordinate | null] {
407+
private _getAnchors(ctx: RenderingContext): [Coordinate | null, Coordinate | null] {
408408
if (!this._viewRange) {
409409
return [null, null];
410410
}
411411

412412
const visibleRangesForRange = ctx.linesVisibleRangesForRange(this._viewRange, false);
413-
const topLeft = getCoordinate(LineVisibleRanges.firstLine(visibleRangesForRange), this._affinity, this._viewRange.startColumn, 0);
414-
const bottomLeft = getCoordinate(LineVisibleRanges.lastLine(visibleRangesForRange), this._affinity, this._viewRange.startColumn, this._lineHeight);
415-
416-
return [topLeft, bottomLeft];
413+
const aboveAnchor = getCoordinate(LineVisibleRanges.firstLine(visibleRangesForRange), this._affinity, this._viewRange.startColumn, 0);
414+
const belowAnchor = getCoordinate(LineVisibleRanges.lastLine(visibleRangesForRange), this._affinity, this._viewRange.startColumn, this._lineHeight);
415+
return [aboveAnchor, belowAnchor];
417416

418417
function getCoordinate(line: LineVisibleRanges | null, affinity: PositionAffinity | null, startColumn: number, deltaTop: number): Coordinate | null {
419418
if (!line) {
@@ -447,8 +446,8 @@ class Widget {
447446
return null;
448447
}
449448

450-
const [topLeft, bottomLeft] = this._getTopAndBottomLeft(ctx);
451-
if (!topLeft || !bottomLeft) {
449+
const [aboveAnchor, belowAnchor] = this._getAnchors(ctx);
450+
if (!aboveAnchor || !belowAnchor) {
452451
return null;
453452
}
454453

@@ -471,9 +470,9 @@ class Widget {
471470

472471
let placement: IBoxLayoutResult | null;
473472
if (this.allowEditorOverflow) {
474-
placement = this._layoutBoxInPage(topLeft, bottomLeft, this._cachedDomNodeOffsetWidth, this._cachedDomNodeOffsetHeight, ctx);
473+
placement = this._layoutBoxInPage(aboveAnchor, belowAnchor, this._cachedDomNodeOffsetWidth, this._cachedDomNodeOffsetHeight, ctx);
475474
} else {
476-
placement = this._layoutBoxInViewport(topLeft, bottomLeft, this._cachedDomNodeOffsetWidth, this._cachedDomNodeOffsetHeight, ctx);
475+
placement = this._layoutBoxInViewport(aboveAnchor, belowAnchor, this._cachedDomNodeOffsetWidth, this._cachedDomNodeOffsetHeight, ctx);
477476
}
478477

479478
// Do two passes, first for perfect fit, second picks first option
@@ -498,9 +497,9 @@ class Widget {
498497
}
499498
} else {
500499
if (this.allowEditorOverflow) {
501-
return { coordinate: this._prepareRenderWidgetAtExactPositionOverflowing(topLeft), position: ContentWidgetPositionPreference.EXACT };
500+
return { coordinate: this._prepareRenderWidgetAtExactPositionOverflowing(aboveAnchor), position: ContentWidgetPositionPreference.EXACT };
502501
} else {
503-
return { coordinate: topLeft, position: ContentWidgetPositionPreference.EXACT };
502+
return { coordinate: aboveAnchor, position: ContentWidgetPositionPreference.EXACT };
504503
}
505504
}
506505
}

0 commit comments

Comments
 (0)