From 3300ec8d025200a2578166660c487d909cab4f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Malbr=C3=A1n?= Date: Sat, 23 Mar 2013 21:42:46 -0300 Subject: [PATCH] Use cursor bottom and text height to handle different font sizes --- src/editor/CodeHintList.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/editor/CodeHintList.js b/src/editor/CodeHintList.js index 30f0238d9e4..31c605c08f7 100644 --- a/src/editor/CodeHintList.js +++ b/src/editor/CodeHintList.js @@ -208,21 +208,22 @@ define(function (require, exports, module) { * @return {{left: number, top: number}} */ CodeHintList.prototype._calcHintListLocation = function () { - var cursor = this.editor._codeMirror.cursorCoords(), - posTop = cursor.top, - posLeft = cursor.left, - $window = $(window), - $menuWindow = this.$hintMenu.children("ul"); + var cursor = this.editor._codeMirror.cursorCoords(), + posTop = cursor.bottom, + posLeft = cursor.left, + textHeight = this.editor.getTextHeight(), + $window = $(window), + $menuWindow = this.$hintMenu.children("ul"), + menuHeight = $menuWindow.outerHeight(); // TODO Ty: factor out menu repositioning logic so code hints and Context menus share code // adjust positioning so menu is not clipped off bottom or right - var bottomOverhang = posTop + 25 + $menuWindow.height() - $window.height(); + var bottomOverhang = posTop + menuHeight - $window.height(); if (bottomOverhang > 0) { - posTop -= (27 + $menuWindow.height()); + posTop -= (textHeight + 2 + menuHeight); } - // todo: should be shifted by line height - posTop -= 15; // shift top for hidden parent element - //posLeft += 5; + + posTop -= 30; // shift top for hidden parent element var rightOverhang = posLeft + $menuWindow.width() - $window.width(); if (rightOverhang > 0) {