diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index a195e372..81aded8a 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -421,6 +421,10 @@ var VirtualRenderer = function(container, theme) { ) this.$computeLayerConfig(); + // horizontal scrolling + if (changes & this.CHANGE_H_SCROLL) + this.scroller.scrollLeft = this.scrollLeft + // full if (changes & this.CHANGE_FULL) { this.$textLayer.update(this.layerConfig); @@ -477,11 +481,6 @@ 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() { @@ -495,9 +494,13 @@ var VirtualRenderer = function(container, theme) { var horizScroll = this.$horizScrollAlwaysVisible || this.$size.scrollerWidth - longestLine < 0; var horizScrollChanged = this.$horizScroll !== horizScroll; this.$horizScroll = horizScroll; - if (horizScrollChanged) + if (horizScrollChanged) { this.scroller.style.overflowX = horizScroll ? "scroll" : "hidden"; - + // when we hide scrollbar scroll event isn't emited + // leaving session with wrong scrollLeft value + if (!horizScroll) + this.session.setScrollLeft(0); + } var maxHeight = this.session.getScreenLength() * this.lineHeight; this.session.setScrollTop(Math.max(0, Math.min(this.scrollTop, maxHeight - this.$size.scrollerHeight)));