fix #1680 Autocomplete box doesn't work with horizontal scrolling

This commit is contained in:
nightwing 2013-11-15 15:53:09 +04:00
commit af7c370318
2 changed files with 9 additions and 3 deletions

View file

@ -78,7 +78,7 @@ var Autocomplete = function() {
var rect = editor.container.getBoundingClientRect();
pos.top += rect.top - renderer.layerConfig.offset;
pos.left += rect.left;
pos.left += rect.left - editor.renderer.scrollLeft;
pos.left += renderer.$gutterLayer.gutterWidth;
this.popup.show(pos, lineHeight);

View file

@ -250,6 +250,7 @@ var AcePopup = function(parentNode) {
popup.show = function(pos, lineHeight, topdownOnly) {
var el = this.container;
var screenHeight = window.innerHeight;
var screenWidth = window.innerWidth;
var renderer = this.renderer;
// var maxLines = Math.min(renderer.$maxLines, this.session.getLength());
var maxH = renderer.$maxLines * lineHeight * 1.4;
@ -265,10 +266,15 @@ var AcePopup = function(parentNode) {
popup.isTopdown = true;
}
el.style.left = pos.left + "px";
el.style.display = "";
this.renderer.$textLayer.checkForSizeChanges();
var left = pos.left;
if (left + el.offsetWidth > screenWidth)
left = screenWidth - el.offsetWidth;
el.style.left = left + "px";
this._signal("show");
lastMouseEvent = null;
popup.isOpen = true;