From 1d9dbe6d3eeba88955e7f85743956427f9618d14 Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Thu, 28 Apr 2011 14:06:03 +0200 Subject: [PATCH] Fix render misalignment. Looks good so far. --- demo/demo.js | 2 +- lib/ace/virtual_renderer.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index f180bfdc..14a661a1 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -157,7 +157,7 @@ exports.launch = function(env) { docs.svg.addFold(new Range(1, 0, 7, 0), "fold..."); docs.plain.addFold(new Range(0, 90, 2, 30), "fold"); - window.s = docs.js; + window.s = docs.plain; window.e = env.editor; setTimeout(function() { env.editor.selection.addEventListener("changeCursor", function() { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index d1d6c3a0..9c813ddc 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -478,6 +478,14 @@ var VirtualRenderer = function(container, theme) { var firstRowScreen, firstRowHeight; var lineHeight = { lineHeight: this.lineHeight }; firstRow = session.screenToDocumentRow(firstRow, 0); + + // Check if firstRow is inside of a foldLine. If true, then use the first + // row of the foldLine. + var foldLine = session.getFoldLine(firstRow); + if (foldLine) { + firstRow = foldLine.start.row; + } + firstRowScreen = session.documentToScreenRow(firstRow, 0); firstRowHeight = session.getRowHeight(lineHeight, firstRow); @@ -501,7 +509,7 @@ var VirtualRenderer = function(container, theme) { }; // For debugging. - console.log(JSON.stringify(layerConfig)); + // console.log(JSON.stringify(layerConfig)); this.$gutterLayer.element.style.marginTop = (-offset) + "px"; this.content.style.marginTop = (-offset) + "px";