improve CSS and HTML auto indent
This commit is contained in:
parent
9f2ecbdb04
commit
ba025f3e87
10 changed files with 132 additions and 19 deletions
33
test/mode/CssTest.js
Normal file
33
test/mode/CssTest.js
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
var CssTest = new TestCase("mode.CssTest", {
|
||||
|
||||
setUp : function() {
|
||||
this.mode = new ace.mode.Css();
|
||||
},
|
||||
|
||||
"test: toggle comment lines should not do anything" : function() {
|
||||
var doc = new ace.TextDocument([" abc", "cde", "fg"].join("\n"));
|
||||
|
||||
var range = {
|
||||
start: {row: 0, column: 3},
|
||||
end: {row: 1, column: 1}
|
||||
};
|
||||
|
||||
var comment = this.mode.toggleCommentLines(doc, range, "start");
|
||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
|
||||
"test: lines should keep indentation" : function() {
|
||||
assertEquals(" ", this.mode.getNextLineIndent(" abc", "start", " "));
|
||||
assertEquals("\t", this.mode.getNextLineIndent("\tabc", "start", " "));
|
||||
},
|
||||
|
||||
"test: new line after { should increase indent" : function() {
|
||||
assertEquals(" ", this.mode.getNextLineIndent(" abc{", "start", " "));
|
||||
assertEquals("\t ", this.mode.getNextLineIndent("\tabc { ", "start", " "));
|
||||
},
|
||||
|
||||
"test: no indent increase after { in a comment" : function() {
|
||||
assertEquals(" ", this.mode.getNextLineIndent(" /*{", "start", " "));
|
||||
}
|
||||
});
|
||||
|
|
@ -24,5 +24,14 @@ var CssTest = new TestCase("mode.CssTest", {
|
|||
|
||||
assertEquals(1, tokens.length);
|
||||
assertEquals("number", tokens[0].type);
|
||||
},
|
||||
|
||||
"test: tokenize parens" : function() {
|
||||
var tokens = this.tokenizer.getLineTokens("{()}", "start").tokens;
|
||||
|
||||
assertEquals(3, tokens.length);
|
||||
assertEquals("lparen", tokens[0].type);
|
||||
assertEquals("text", tokens[1].type);
|
||||
assertEquals("rparen", tokens[2].type);
|
||||
}
|
||||
});
|
||||
|
|
@ -37,5 +37,16 @@ var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
|||
assertEquals("doc-comment", tokens[0].type);
|
||||
assertEquals("doc-comment-tag", tokens[1].type);
|
||||
assertEquals("doc-comment", tokens[2].type);
|
||||
},
|
||||
|
||||
"test: tokenize parens" : function() {
|
||||
var line = "[{( )}]";
|
||||
|
||||
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
|
||||
|
||||
assertEquals(3, tokens.length);
|
||||
assertEquals("lparen", tokens[0].type);
|
||||
assertEquals("text", tokens[1].type);
|
||||
assertEquals("rparen", tokens[2].type);
|
||||
}
|
||||
});
|
||||
23
test/mode/TextTest.js
Normal file
23
test/mode/TextTest.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
var TextTest = new TestCase("mode.TextTest", {
|
||||
|
||||
setUp : function() {
|
||||
this.mode = new ace.mode.Text();
|
||||
},
|
||||
|
||||
"test: toggle comment lines should not do anything" : function() {
|
||||
var doc = new ace.TextDocument([" abc", "cde", "fg"].join("\n"));
|
||||
|
||||
var range = {
|
||||
start: {row: 0, column: 3},
|
||||
end: {row: 1, column: 1}
|
||||
};
|
||||
|
||||
var comment = this.mode.toggleCommentLines(doc, range, "start");
|
||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
|
||||
"text: lines should not be indented" : function() {
|
||||
assertEquals("", this.mode.getNextLineIndent(" abc", " "));
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue