diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 6f0f5e2a..a195e372 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -171,6 +171,7 @@ var VirtualRenderer = function(container, theme) { this.CHANGE_MARKER_BACK = 128; this.CHANGE_MARKER_FRONT = 256; this.CHANGE_FULL = 512; + this.CHANGE_H_SCROLL = 1024; oop.implement(this, EventEmitter); @@ -476,6 +477,11 @@ var VirtualRenderer = function(container, theme) { if (changes & this.CHANGE_SIZE) this.$updateScrollBar(); + + if (changes & this.CHANGE_H_SCROLL) { + //this.content.style.left = -this.scrollLeft + "px"; + this.scroller.scrollLeft = this.scrollLeft + } }; this.$computeLayerConfig = function() { @@ -542,12 +548,6 @@ var VirtualRenderer = function(container, theme) { this.content.style.width = longestLine + 2 * this.$padding + "px"; this.content.style.height = minHeight + "px"; - // scroller.scrollWidth was smaller than scrollLeft we needed - if (this.$desiredScrollLeft) { - this.scrollToX(this.$desiredScrollLeft); - this.$desiredScrollLeft = 0; - } - // Horizontal scrollbar visibility may have changed, which changes // the client height of the scroller if (horizScrollChanged) @@ -653,14 +653,11 @@ var VirtualRenderer = function(container, theme) { if (scrollLeft > left) { if (left < this.$padding + 2 * this.layerConfig.characterWidth) left = 0; - this.scrollToX(left); + this.session.setScrollLeft(left); } if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { - if (left > this.layerConfig.width + 2 * this.$padding) - this.$desiredScrollLeft = left; - else - this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); + this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); } }; @@ -706,8 +703,10 @@ var VirtualRenderer = function(container, theme) { if (scrollLeft <= this.$padding) scrollLeft = 0; - this.scroller.scrollLeft = scrollLeft; - scrollLeft = this.scroller.scrollLeft; + if (this.scrollLeft !== scrollLeft) { + this.$loop.schedule(this.CHANGE_H_SCROLL); + this.scrollLeft = scrollLeft; + } }; this.scrollBy = function(deltaX, deltaY) {