From 155115035c902d0f5b273fa1672d4964b2c2437c Mon Sep 17 00:00:00 2001 From: Julian Viereck Date: Mon, 25 Apr 2011 23:25:08 +0200 Subject: [PATCH] Fix rendering bugs. Make SVG session default for testing. --- demo/demo.js | 2 ++ index.html | 3 ++- lib/ace/layer/text.js | 15 +++++---------- lib/ace/virtual_renderer.js | 5 ++++- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index 7103d3e7..66bc9c6b 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -152,6 +152,8 @@ exports.launch = function(env) { docs.js.addFold(new Range(0, 13, 0, 18), "args..."); docs.js.addFold(new Range(2, 20, 2, 25), "bar..."); docs.js.addFold(new Range(1, 10, 2, 10), "foo..."); + + docs.svg.addFold(new Range(1, 0, 7, 0), "fold..."); window.s = docs.js; window.e = env.editor; setTimeout(function() { diff --git a/index.html b/index.html index c79abe0f..a4dcc834 100644 --- a/index.html +++ b/index.html @@ -14,6 +14,7 @@ diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 60bc771a..a94a368c 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -231,11 +231,11 @@ var Text = function(parentEl) { var el = this.element; if (oldConfig.firstRow < config.firstRow) - for (var row=oldConfig.firstRow; row config.lastRow) - for (var row=config.lastRow+1; row<=oldConfig.lastRow; row++) + for (var row=config.lastRow+1; row<=oldConfig.lastRow; row = this.session.getRowFoldEnd(row) + 1) el.removeChild(el.lastChild); if (config.firstRow < oldConfig.firstRow) { @@ -402,13 +402,6 @@ var Text = function(parentEl) { } this.$renderLine = function(stringBuilder, row, tokens) { - // Nothing to do if the entire line is folded. - // TODO: Remove this, once the folding feature is done. Only for - // developing stuff at the moment. -// if (!this.session.isRowVisible(row)) { -// throw "Calling renderLine on folded line doesn't make sense?"; -// } - // Check if the line to render is folded or not. If not, things are // simple, otherwise, we need to fake some things... if (!this.session.isRowFolded(row)) { @@ -474,7 +467,9 @@ var Text = function(parentEl) { if (isNewRow) { tokens = this.tokenizer.getTokens(row, row)[0].tokens; } - addTokens(tokens, lastColumn, column); + if (tokens.length != 0) { + addTokens(tokens, lastColumn, column); + } } }.bind(this), foldLine.end.row, this.session.getLine(foldLine.end.row).length); diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 964e7b27..01b6ca1c 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -478,7 +478,7 @@ var VirtualRenderer = function(container, theme) { var firstRowScreen, firstRowHeight; var lineHeight = { lineHeight: this.lineHeight }; firstRow = session.screenToDocumentRow(firstRow, 0); - firstRowScreen = session.documentToScreenRow(firstRow); + firstRowScreen = session.documentToScreenRow(firstRow, 0); firstRowHeight = session.getRowHeight(lineHeight, firstRow); lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1); @@ -500,6 +500,9 @@ var VirtualRenderer = function(container, theme) { height : this.$size.scrollerHeight }; + // For debugging. + // console.log(JSON.stringify(layerConfig)); + this.$gutterLayer.element.style.marginTop = (-offset) + "px"; this.content.style.marginTop = (-offset) + "px"; this.content.style.width = longestLine + "px";