Skip to content

Commit aca92ea

Browse files
committed
fix bug in show-hints inset
1 parent 1df33b7 commit aca92ea

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

addon/hint/show-hint.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,10 @@
255255
}
256256

257257
var container = completion.options.container || ownerDocument.body;
258+
var marginBottom = completion.options.marginBottom || 0;
258259
var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
259-
var left = pos.left, top = pos.bottom, below = true;
260-
var offsetLeft = 0, offsetTop = 0;
260+
var left = pos.left, top = pos.bottom, bottom = pos.top, below = true;
261+
var offsetLeft = 0, offsetTop = 0, offsetBottom = 0;
261262
if (container !== ownerDocument.body) {
262263
// We offset the cursor position because left and top are relative to the offsetParent's top left corner.
263264
var isContainerPositioned = ['absolute', 'relative', 'fixed'].indexOf(parentWindow.getComputedStyle(container).position) !== -1;
@@ -266,6 +267,7 @@
266267
var bodyPosition = ownerDocument.body.getBoundingClientRect();
267268
offsetLeft = (offsetParentPosition.left - bodyPosition.left - offsetParent.scrollLeft);
268269
offsetTop = (offsetParentPosition.top - bodyPosition.top - offsetParent.scrollTop);
270+
offsetBottom = (offsetParentPosition.bottom - bodyPosition.bottom);
269271
}
270272
hints.style.left = (left - offsetLeft) + "px";
271273
hints.style.top = (top - offsetTop) + "px";
@@ -285,12 +287,13 @@
285287
var startScroll;
286288
setTimeout(function() { startScroll = cm.getScrollInfo(); });
287289

288-
var overlapY = box.bottom - winH;
290+
var overlapY = box.bottom + marginBottom - winH;
289291
if (overlapY > 0) { // Does not fit below
290292
var height = box.bottom - box.top, spaceAbove = box.top - (pos.bottom - pos.top) - 2
291293
if (winH - box.top < spaceAbove) { // More room at the top
292294
if (height > spaceAbove) hints.style.height = (height = spaceAbove) + "px";
293-
hints.style.top = ((top = pos.top - height) + offsetTop) + "px";
295+
hints.style.top = "auto";
296+
hints.style.bottom = (winH - (bottom - offsetBottom)) + "px";
294297
below = false;
295298
} else {
296299
hints.style.height = (winH - box.top - 2) + "px";

0 commit comments

Comments
 (0)