From 2df81fffae8269f1ecfb58fd8e6917a25ac64462 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Sun, 9 Jan 2011 11:20:00 +0100 Subject: [PATCH] VirtualRenderer: Fix buggy offset --- lib/ace/virtual_renderer.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index e405b6f8..51550989 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -146,7 +146,6 @@ var VirtualRenderer = function(container, theme) { * Triggers partial update of the text layer */ this.updateLines = function(firstRow, lastRow) { - console.log("updateLines", firstRow, lastRow); if (lastRow === undefined) lastRow = Infinity; @@ -399,17 +398,20 @@ var VirtualRenderer = function(container, theme) { var lineCount = Math.ceil(minHeight / this.lineHeight); var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight)); - //var lastRow = Math.max(0, Math.min(this.lines.length, firstRow + lineCount) - 1); - var lastRow = firstRow + lineCount - 1; + var lastRow = firstRow + lineCount; - // Add support for wrapped lines. + // Map lines on the screen to lines in the document. + var firstRowScreen, firstRowHeight; var lineHeight = { lineHeight: this.lineHeight }; firstRow = this.doc.screenToDocumentRow(firstRow); - var firstRowScreen = this.doc.documentToScreenRow(firstRow); - lastRow = Math.min(this.doc.screenToDocumentRow(lastRow), this.doc.lines.length - 1); - offset = this.scrollTop % this.doc.getRowHeight(lineHeight, firstRow); - console.log("renderer.computeLayerConfig", firstRow, lastRow); + firstRowScreen = this.doc.documentToScreenRow(firstRow); + firstRowHeight = this.doc.getRowHeight(lineHeight, firstRow); + lastRow = Math.min(this.doc.screenToDocumentRow(lastRow), this.doc.lines.length - 1); + minHeight = this.$size.scrollerHeight + this.doc.getRowHeight(lineHeight, lastRow)+ + firstRowHeight; + + offset = this.scrollTop - firstRowScreen * this.lineHeight; var layerConfig = this.layerConfig = { width : longestLine,