src/vs/editor/contrib/suggest/suggestWidgetDetails.ts/SuggestDetailsOverlay/_placeAtAnchor
class SuggestDetailsOverlay:	_placeAtAnchor(anchorBox: dom.IDomNodePagePosition, size: dom.Dimension) {
		const bodyBox = dom.getClientArea(document.body);

		const info = this.widget.getLayoutInfo();

		let maxSizeTop: dom.Dimension;
		let maxSizeBottom: dom.Dimension;
		let minSize = new dom.Dimension(220, 2 * info.lineHeight);

		let left = 0;
		let top = anchorBox.top;
		let bottom = anchorBox.top + anchorBox.height - info.borderHeight;

		let alignAtTop: boolean;
		let alignEast: boolean;

		// position: EAST, west, south
		let width = bodyBox.width - (anchorBox.left + anchorBox.width + info.borderWidth + info.horizontalPadding);
		left = -info.borderWidth + anchorBox.left + anchorBox.width;
		alignEast = true;
		maxSizeTop = new dom.Dimension(width, bodyBox.height - anchorBox.top - info.borderHeight - info.verticalPadding);
		maxSizeBottom = maxSizeTop.with(undefined, anchorBox.top + anchorBox.height - info.borderHeight - info.verticalPadding);

		// find a better place if the widget is wider than there is space available
		if (size.width > width) {
			// position: east, WEST, south
			if (anchorBox.left > width) {
				// pos = SuggestDetailsPosition.West;
				width = anchorBox.left - info.borderWidth - info.horizontalPadding;
				alignEast = false;
				left = Math.max(info.horizontalPadding, anchorBox.left - size.width - info.borderWidth);
				maxSizeTop = maxSizeTop.with(width);
				maxSizeBottom = maxSizeTop.with(undefined, maxSizeBottom.height);
			}

			// position: east, west, SOUTH
			if (anchorBox.width > width * 1.3 && bodyBox.height - (anchorBox.top + anchorBox.height) > anchorBox.height) {
				width = anchorBox.width;
				left = anchorBox.left;
				top = -info.borderWidth + anchorBox.top + anchorBox.height;
				maxSizeTop = new dom.Dimension(anchorBox.width - info.borderHeight, bodyBox.height - anchorBox.top - anchorBox.height - info.verticalPadding);
				maxSizeBottom = maxSizeTop.with(undefined, anchorBox.top - info.verticalPadding);
				minSize = minSize.with(maxSizeTop.width);
			}
		}

		// top/bottom placement
		let height = size.height;
		let maxHeight = Math.max(maxSizeTop.height, maxSizeBottom.height);
		if (height > maxHeight) {
			height = maxHeight;
		}
		let maxSize: dom.Dimension;
		if (height <= maxSizeTop.height) {
			alignAtTop = true;
			maxSize = maxSizeTop;
		} else {
			alignAtTop = false;
			maxSize = maxSizeBottom;
		}

		this._applyTopLeft({ left, top: alignAtTop ? top : bottom - height });
		this.getDomNode().style.position = 'fixed';

		this._resizable.enableSashes(!alignAtTop, alignEast, alignAtTop, !alignEast);

		this._resizable.minSize = minSize;
		this._resizable.maxSize = maxSize;
		this._resizable.layout(height, Math.min(maxSize.width, size.width));
		this.widget.layout(this._resizable.size.width, this._resizable.size.height);
	}