diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js
index b14459eb..6ad0ca82 100644
--- a/lib/ace/layer/text.js
+++ b/lib/ace/layer/text.js
@@ -352,10 +352,11 @@ var Text = function(parentEl) {
} else if (c == "\u3000") {
// U+3000 is both invisible AND full-width, so must be handled uniquely
var classToUse = self.showInvisibles ? "ace_cjk ace_invisible" : "ace_cjk";
+ var space = self.showInvisibles ? self.SPACE_CHAR : "";
screenColumn += 1;
return "" + c + "";
+ "px'>" + space + "";
} else if (c.match(/[\v\f \u00a0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000]/)) {
if (self.showInvisibles) {
var space = new Array(c.length+1).join(self.SPACE_CHAR);
@@ -449,7 +450,8 @@ var Text = function(parentEl) {
else
stringBuilder.push("" + this.EOF_CHAR + "");
}
- stringBuilder.push("");
+ if (!onlyContents)
+ stringBuilder.push("");
};
this.$renderLine = function(stringBuilder, row, tokens, onlyContents) {
diff --git a/lib/ace/layer/text_text.js b/lib/ace/layer/text_test.js
similarity index 65%
rename from lib/ace/layer/text_text.js
rename to lib/ace/layer/text_test.js
index bf6cf1be..7298633a 100644
--- a/lib/ace/layer/text_text.js
+++ b/lib/ace/layer/text_test.js
@@ -49,29 +49,52 @@ var JavaScriptMode = require("ace/mode/javascript").Mode;
module.exports = {
- "test: render line with hard tabs should render the same as lines with soft tabs" : function() {
- var session = new EditSession("a\ta\ta\t\na a a \n");
- session.setMode(new JavaScriptMode());
- var textLayer = new TextLayer(document.createElement("div"));
- textLayer.setSession(session);
- textLayer.$computeTabString();
- textLayer.config = {
+ setUp: function(next) {
+ this.session = new EditSession("");
+ this.session.setMode(new JavaScriptMode());
+ this.textLayer = new TextLayer(document.createElement("div"));
+ this.textLayer.setSession(this.session);
+ this.textLayer.config = {
characterWidth: 10,
lineHeight: 20
};
+ next()
+ },
+
+ "test: render line with hard tabs should render the same as lines with soft tabs" : function() {
+ this.session.setValue("a\ta\ta\t\na a a \n");
+ this.textLayer.$computeTabString();
// row with hard tabs
var row = 0;
- var tokens = session.getTokens(row, row)[0].tokens;
+ var tokens = this.session.getTokens(row, row)[0].tokens;
var stringBuilder = [];
- textLayer.$renderLine(stringBuilder, row, tokens);
+ this.textLayer.$renderLine(stringBuilder, row, tokens);
// row with soft tabs
row = 1;
- tokens = session.getTokens(row, row)[0].tokens;
+ tokens = this.session.getTokens(row, row)[0].tokens;
var stringBuilder2 = [];
- textLayer.$renderLine(stringBuilder2, row, tokens);
+ this.textLayer.$renderLine(stringBuilder2, row, tokens);
assert.equal(stringBuilder.join(""), stringBuilder2.join(""));
+ },
+
+ "test rendering width of ideographic space (U+3000)" : function() {
+ this.session.setValue("\u3000");
+
+ var tokens = this.session.getTokens(0, 0)[0].tokens;
+ var stringBuilder = [];
+ this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
+ assert.equal(stringBuilder.join(""), "");
+
+ this.textLayer.setShowInvisibles(true);
+ var stringBuilder = [];
+ this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
+ assert.equal(
+ stringBuilder.join(""),
+ "" + this.textLayer.SPACE_CHAR + ""
+ + "¶"
+ );
}
};