From 67ba8f5f29ed1d0c3b3d31229d5597a99860f21c Mon Sep 17 00:00:00 2001 From: mikedeboer Date: Thu, 2 Feb 2012 12:21:37 +0100 Subject: [PATCH] fixed horizontal scroll restore when browser and ACE are out of sync --- build/src/ace-uncompressed.js | 9 ++++----- lib/ace/virtual_renderer.js | 11 +++++------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/build/src/ace-uncompressed.js b/build/src/ace-uncompressed.js index aa00f629..6e1560f0 100644 --- a/build/src/ace-uncompressed.js +++ b/build/src/ace-uncompressed.js @@ -11961,7 +11961,7 @@ var VirtualRenderer = function(container, theme) { }; this.$renderChanges = function(changes) { - if (!changes || !this.session) + if (!changes || !this.session || !this.container.offsetWidth) return; // text, scrolling and resize changes can cause the view port size to change @@ -11980,7 +11980,7 @@ var VirtualRenderer = function(container, theme) { // full if (changes & this.CHANGE_FULL) { this.$textLayer.checkForSizeChanges(); - // update scrollbar first to not loose scroll position when gutter calls resize + // update scrollbar first to not lose scroll position when gutter calls resize this.$updateScrollBar(); this.$textLayer.update(this.layerConfig); if (this.showGutter) @@ -12262,10 +12262,9 @@ var VirtualRenderer = function(container, theme) { if (scrollLeft <= this.$padding) scrollLeft = 0; - if (this.scrollLeft !== scrollLeft) { - this.$loop.schedule(this.CHANGE_H_SCROLL); + if (this.scrollLeft !== scrollLeft) this.scrollLeft = scrollLeft; - } + this.$loop.schedule(this.CHANGE_H_SCROLL); }; this.scrollBy = function(deltaX, deltaY) { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index b5fc4289..4cef8254 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -409,7 +409,7 @@ var VirtualRenderer = function(container, theme) { }; this.$renderChanges = function(changes) { - if (!changes || !this.session) + if (!changes || !this.session || !this.container.offsetWidth) return; // text, scrolling and resize changes can cause the view port size to change @@ -423,12 +423,12 @@ var VirtualRenderer = function(container, theme) { // horizontal scrolling if (changes & this.CHANGE_H_SCROLL) - this.scroller.scrollLeft = this.scrollLeft + this.scroller.scrollLeft = this.scrollLeft; // full if (changes & this.CHANGE_FULL) { this.$textLayer.checkForSizeChanges(); - // update scrollbar first to not loose scroll position when gutter calls resize + // update scrollbar first to not lose scroll position when gutter calls resize this.$updateScrollBar(); this.$textLayer.update(this.layerConfig); if (this.showGutter) @@ -710,10 +710,9 @@ var VirtualRenderer = function(container, theme) { if (scrollLeft <= this.$padding) scrollLeft = 0; - if (this.scrollLeft !== scrollLeft) { - this.$loop.schedule(this.CHANGE_H_SCROLL); + if (this.scrollLeft !== scrollLeft) this.scrollLeft = scrollLeft; - } + this.$loop.schedule(this.CHANGE_H_SCROLL); }; this.scrollBy = function(deltaX, deltaY) {