From c62b0b134f23a8eb62a29825749c06f95d27169f Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 21 Sep 2014 00:04:01 +0400 Subject: [PATCH] fix regression in ace_popup --- lib/ace/virtual_renderer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index c6303626..87c3fa90 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -816,10 +816,15 @@ var VirtualRenderer = function(container, theme) { // lines may have been pushed down. If so, the first screen row will not // have changed, but the first actual row will. In that case, adjust // scrollTop so that the cursor and onscreen content stays in the same place. + // TODO: find a better way to handle this, that works non wrapped case and doesn't compute layerConfig twice if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) { - this.scrollTop = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight; - changes = changes | this.CHANGE_SCROLL; - changes |= this.$computeLayerConfig(); + var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight; + if (st > 0) { + // this check is needed as a workaround for the documentToScreenRow returning -1 if document.length == 0 + this.scrollTop = st; + changes = changes | this.CHANGE_SCROLL; + changes |= this.$computeLayerConfig(); + } } config = this.layerConfig; // update scrollbar first to not lose scroll position when gutter calls resize