Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit ad246f3

Browse files
committed
Merge pull request #3232 from TomMalbran/tom/fix-issue-3228
Fix #3228: Codehints selection popup is positioned wrong when the font size is not standard
2 parents ebab357 + 3300ec8 commit ad246f3

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/editor/CodeHintList.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -208,21 +208,22 @@ define(function (require, exports, module) {
208208
* @return {{left: number, top: number}}
209209
*/
210210
CodeHintList.prototype._calcHintListLocation = function () {
211-
var cursor = this.editor._codeMirror.cursorCoords(),
212-
posTop = cursor.top,
213-
posLeft = cursor.left,
214-
$window = $(window),
215-
$menuWindow = this.$hintMenu.children("ul");
211+
var cursor = this.editor._codeMirror.cursorCoords(),
212+
posTop = cursor.bottom,
213+
posLeft = cursor.left,
214+
textHeight = this.editor.getTextHeight(),
215+
$window = $(window),
216+
$menuWindow = this.$hintMenu.children("ul"),
217+
menuHeight = $menuWindow.outerHeight();
216218

217219
// TODO Ty: factor out menu repositioning logic so code hints and Context menus share code
218220
// adjust positioning so menu is not clipped off bottom or right
219-
var bottomOverhang = posTop + 25 + $menuWindow.height() - $window.height();
221+
var bottomOverhang = posTop + menuHeight - $window.height();
220222
if (bottomOverhang > 0) {
221-
posTop -= (27 + $menuWindow.height());
223+
posTop -= (textHeight + 2 + menuHeight);
222224
}
223-
// todo: should be shifted by line height
224-
posTop -= 15; // shift top for hidden parent element
225-
//posLeft += 5;
225+
226+
posTop -= 30; // shift top for hidden parent element
226227

227228
var rightOverhang = posLeft + $menuWindow.width() - $window.width();
228229
if (rightOverhang > 0) {

0 commit comments

Comments
 (0)