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

Fix #3228: Codehints selection popup is positioned wrong when the font size is not standard #3232

Merged
merged 1 commit into from
Mar 29, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/editor/CodeHintList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down