diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index d55d6085..33f3a906 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -234,7 +234,7 @@ var VirtualRenderer = function(container, theme) { this.session = session; if (!session) return; - + if (this.scrollMargin.top && session.getScrollTop() <= 0) session.setScrollTop(-this.scrollMargin.top); @@ -337,8 +337,6 @@ var VirtualRenderer = function(container, theme) { * **/ this.onResize = function(force, gutterWidth, width, height) { - // if (force) - // console.log("force resize requested", width, height) if (this.resizing > 2) return; else if (this.resizing > 0) @@ -353,13 +351,7 @@ var VirtualRenderer = function(container, theme) { if (!width) width = el.clientWidth || el.scrollWidth; var changes = this.$updateCachedSize(force, gutterWidth, width, height); - - // console.log("resizing to", width, height, JSON.stringify(this.$size)) - // setTimeout(function() { - // console.log("actual size ", this.container.clientWidth, this.container.clientHeight) - - // }.bind(this), 500) if (!this.$size.scrollerHeight || (!width && !height)) return this.resizing = 0; @@ -757,7 +749,16 @@ var VirtualRenderer = function(container, theme) { }; this.$updateScrollBarV = function() { - this.scrollBarV.setScrollHeight(this.layerConfig.maxHeight + this.scrollMargin.v); + var scrollHeight = this.layerConfig.maxHeight; + var scrollerHeight = this.$size.scrollerHeight; + if (!this.$maxLines && this.$scrollPastEnd) { + scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd; + if (this.scrollTop > scrollHeight - scrollerHeight) { + scrollHeight = this.scrollTop + scrollerHeight; + this.scrollBarV.scrollTop = null; + } + } + this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v); this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top); }; this.$updateScrollBarH = function() { @@ -934,11 +935,7 @@ var VirtualRenderer = function(container, theme) { } if (!this.$maxLines && this.$scrollPastEnd) { - if (this.scrollTop > maxHeight - size.scrollerHeight) - maxHeight += Math.min( - (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd, - this.scrollTop - maxHeight + size.scrollerHeight - ); + maxHeight += (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd; } var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible || @@ -1373,8 +1370,7 @@ var VirtualRenderer = function(container, theme) { if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top) return true; if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight - - this.layerConfig.maxHeight - (this.$size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd - < -1 + this.scrollMargin.bottom) + - this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom) return true; if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left) return true;