update tests
This commit is contained in:
parent
f73e38625b
commit
5e7434bdbb
4 changed files with 39 additions and 14 deletions
|
|
@ -218,7 +218,6 @@ var Editor = function(renderer, session) {
|
||||||
this.onChangeBreakpoint();
|
this.onChangeBreakpoint();
|
||||||
this.onChangeAnnotation();
|
this.onChangeAnnotation();
|
||||||
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
|
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
|
||||||
this.renderer.onChangeTabSize();
|
|
||||||
this.renderer.updateFull();
|
this.renderer.updateFull();
|
||||||
|
|
||||||
this._emit("changeSession", {
|
this._emit("changeSession", {
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,10 @@ exports.render = function(input, mode, theme, lineStart, disableGutter) {
|
||||||
var length = session.getLength();
|
var length = session.getLength();
|
||||||
|
|
||||||
for(var ix = 0; ix < length; ix++) {
|
for(var ix = 0; ix < length; ix++) {
|
||||||
var lineTokens = session.getTokens(ix);
|
|
||||||
stringBuilder.push("<div class='ace_line'>");
|
stringBuilder.push("<div class='ace_line'>");
|
||||||
if (!disableGutter)
|
if (!disableGutter)
|
||||||
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
|
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
|
||||||
textLayer.$renderLine(stringBuilder, 0, lineTokens, true);
|
textLayer.$renderLine(stringBuilder, 0, true, false);
|
||||||
stringBuilder.push("</div>");
|
stringBuilder.push("</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,7 @@ var Text = function(parentEl) {
|
||||||
|
|
||||||
this.setSession = function(session) {
|
this.setSession = function(session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
this.$computeTabString();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.showInvisibles = false;
|
this.showInvisibles = false;
|
||||||
|
|
|
||||||
|
|
@ -67,35 +67,61 @@ module.exports = {
|
||||||
this.textLayer.$computeTabString();
|
this.textLayer.$computeTabString();
|
||||||
|
|
||||||
// row with hard tabs
|
// row with hard tabs
|
||||||
var row = 0;
|
|
||||||
var tokens = this.session.getTokens(row);
|
|
||||||
var stringBuilder = [];
|
var stringBuilder = [];
|
||||||
this.textLayer.$renderLine(stringBuilder, row, tokens);
|
this.textLayer.$renderLine(stringBuilder, 0);
|
||||||
|
|
||||||
// row with soft tabs
|
// row with soft tabs
|
||||||
row = 1;
|
|
||||||
tokens = this.session.getTokens(row);
|
|
||||||
var stringBuilder2 = [];
|
var stringBuilder2 = [];
|
||||||
this.textLayer.$renderLine(stringBuilder2, row, tokens);
|
this.textLayer.$renderLine(stringBuilder2, 1);
|
||||||
assert.equal(stringBuilder.join(""), stringBuilder2.join(""));
|
assert.equal(stringBuilder.join(""), stringBuilder2.join(""));
|
||||||
},
|
},
|
||||||
|
|
||||||
"test rendering width of ideographic space (U+3000)" : function() {
|
"test rendering width of ideographic space (U+3000)" : function() {
|
||||||
this.session.setValue("\u3000");
|
this.session.setValue("\u3000");
|
||||||
|
|
||||||
var tokens = this.session.getTokens(0);
|
|
||||||
var stringBuilder = [];
|
var stringBuilder = [];
|
||||||
this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
|
this.textLayer.$renderLine(stringBuilder, 0, true);
|
||||||
assert.equal(stringBuilder.join(""), "<span class='ace_cjk' style='width:20px'></span>");
|
assert.equal(stringBuilder.join(""), "<span class='ace_cjk' style='width:20px'></span>");
|
||||||
|
|
||||||
this.textLayer.setShowInvisibles(true);
|
this.textLayer.setShowInvisibles(true);
|
||||||
var stringBuilder = [];
|
var stringBuilder = [];
|
||||||
this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
|
this.textLayer.$renderLine(stringBuilder, 0, true);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
stringBuilder.join(""),
|
stringBuilder.join(""),
|
||||||
"<span class='ace_cjk ace_invisible' style='width:20px'>" + this.textLayer.SPACE_CHAR + "</span>"
|
"<span class='ace_cjk ace_invisible' style='width:20px'>" + this.textLayer.SPACE_CHAR + "</span>"
|
||||||
+ "<span class='ace_invisible'>\xB6</span>"
|
+ "<span class='ace_invisible'>\xB6</span>"
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test rendering of indent guides" : function() {
|
||||||
|
var textLayer = this.textLayer
|
||||||
|
var EOL = "<span class='ace_invisible'>" + textLayer.EOL_CHAR + "</span>";
|
||||||
|
var SPACE = function(i) {return Array(i+1).join(" ")}
|
||||||
|
var TAB = function(i) {return textLayer.TAB_CHAR + SPACE(i-1)}
|
||||||
|
function testRender(results) {
|
||||||
|
for (var i = results.length; i--; ) {
|
||||||
|
var stringBuilder = [];
|
||||||
|
textLayer.$renderLine(stringBuilder, i, true);
|
||||||
|
assert.equal(stringBuilder.join(""), results[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.session.setValue(" \n\t\tf\n ");
|
||||||
|
testRender([
|
||||||
|
"<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(2),
|
||||||
|
"<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(4) + "<span class='ace_identifier'>f</span>",
|
||||||
|
SPACE(3)
|
||||||
|
]);
|
||||||
|
this.textLayer.setShowInvisibles(true);
|
||||||
|
testRender([
|
||||||
|
"<span class='ace_indent-guide ace_invisible'>" + SPACE(4) + "</span>" + SPACE(2) + EOL,
|
||||||
|
"<span class='ace_indent-guide ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL,
|
||||||
|
]);
|
||||||
|
this.textLayer.setDisplayIndentGuides(false);
|
||||||
|
testRender([
|
||||||
|
SPACE(6) + EOL,
|
||||||
|
"<span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue