From 8fc9dac030bd6e7ebc1d7b6bd64efe4c96ba7041 Mon Sep 17 00:00:00 2001 From: nightwing Date: Mon, 23 May 2011 18:28:50 +0500 Subject: [PATCH] same for the horizontal scrollbar --- lib/ace/virtual_renderer.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 31a9eeff..64445e81 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -520,6 +520,12 @@ var VirtualRenderer = function(container, theme) { this.content.style.width = longestLine + "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) @@ -620,16 +626,17 @@ var VirtualRenderer = function(container, theme) { this.scrollToY(top + this.lineHeight - this.$size.scrollerHeight); } - if (this.scroller.scrollLeft > left) { + var scrollLeft = this.scroller.scrollLeft; + + if (scrollLeft > left) { this.scrollToX(left); } - if (this.scroller.scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { - - if (left + this.characterWidth > this.scroller.scrollWidth) - this.$renderChanges(this.CHANGE_SIZE); - - this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); + if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { + if (left > this.layerConfig.width) + this.$desiredScrollLeft = left + 2 * this.characterWidth; + else + this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); } },