From 86100b5ebe9ec081f08dbd8a3a76fd45aa94b109 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 21 Aug 2012 20:20:02 +0400 Subject: [PATCH] fix static_highlight --- lib/ace/ext/static_highlight.js | 4 ++-- lib/ace/ext/static_highlight_test.js | 23 +++++++++-------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/ace/ext/static_highlight.js b/lib/ace/ext/static_highlight.js index 08cc4004..24c97195 100644 --- a/lib/ace/ext/static_highlight.js +++ b/lib/ace/ext/static_highlight.js @@ -70,12 +70,12 @@ exports.render = function(input, mode, theme, lineStart, disableGutter) { var stringBuilder = []; var length = session.getLength(); - + for(var ix = 0; ix < length; ix++) { stringBuilder.push("
"); if (!disableGutter) stringBuilder.push("" + (ix + lineStart) + ""); - textLayer.$renderLine(stringBuilder, 0, true, false); + textLayer.$renderLine(stringBuilder, ix, true, false); stringBuilder.push("
"); } diff --git a/lib/ace/ext/static_highlight_test.js b/lib/ace/ext/static_highlight_test.js index f6e5c909..707d00ea 100644 --- a/lib/ace/ext/static_highlight_test.js +++ b/lib/ace/ext/static_highlight_test.js @@ -16,7 +16,8 @@ module.exports = { "test simple snippet": function(next) { var theme = require("../theme/tomorrow"); - var snippet = "/** this is a function\n\ + var snippet = "\ +/** this is a function\n\ *\n\ */\n\ function hello (a, b, c) {\n\ @@ -24,23 +25,16 @@ function hello (a, b, c) {\n\ }"; var mode = new JavaScriptMode(); - var isError = false, result; - try { - result = highlighter.render(snippet, mode, theme); - } - catch (e) { - console.log(e); - isError = true; - } - // todo: write something more meaningful - assert.equal(isError, false); - + var result = highlighter.render(snippet, mode, theme); + assert.equal(result.html, "
1/** this is a function
2*
3*/
4function hello (abc) {
5    console.log(a * b + c + 'sup?');
6}
"); + assert.ok(!!result.css); next(); }, "test css from theme is used": function(next) { var theme = require("../theme/tomorrow"); - var snippet = "/** this is a function\n\ + var snippet = "\ +/** this is a function\n\ *\n\ */\n\ function hello (a, b, c) {\n\ @@ -58,7 +52,8 @@ function hello (a, b, c) {\n\ "test theme classname should be in output html": function (next) { var theme = require("../theme/tomorrow"); - var snippet = "/** this is a function\n\ + var snippet = "\ +/** this is a function\n\ *\n\ */\n\ function hello (a, b, c) {\n\