Autoindent for XML and HTML modes
This commit is contained in:
parent
144a4ef502
commit
e12ff69a4e
4 changed files with 36 additions and 1 deletions
|
|
@ -17,8 +17,9 @@ ace.inherits(ace.mode.Html, ace.mode.Text);
|
|||
};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var self = this;
|
||||
return this.$delegate("getNextLineIndent", arguments, function() {
|
||||
return "";
|
||||
return self.$getIndent(line);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,3 +4,11 @@ ace.mode.Xml = function() {
|
|||
this.$tokenizer = new ace.Tokenizer(new ace.mode.XmlHighlightRules().getRules());
|
||||
};
|
||||
ace.inherits(ace.mode.Xml, ace.mode.Text);
|
||||
|
||||
(function() {
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
return this.$getIndent(line);
|
||||
};
|
||||
|
||||
}).call(ace.mode.Xml.prototype);
|
||||
20
src/test/ace/mode/HtmlTest.js
Normal file
20
src/test/ace/mode/HtmlTest.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
var HtmlTest = new TestCase("mode.HtmlTest", {
|
||||
|
||||
setUp : function() {
|
||||
this.mode = new ace.mode.Html();
|
||||
},
|
||||
|
||||
"test: toggle comment lines should not do anything" : function() {
|
||||
var doc = new ace.Document([" abc", "cde", "fg"]);
|
||||
|
||||
var range = new ace.Range(0, 3, 1, 1);
|
||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
"test: next line indent should be the same as the current line indent" : function() {
|
||||
assertEquals(" ", this.mode.getNextLineIndent("start", " abc"));
|
||||
assertEquals("", this.mode.getNextLineIndent("start", "abc"));
|
||||
assertEquals("\t", this.mode.getNextLineIndent("start", "\tabc"));
|
||||
}
|
||||
});
|
||||
|
|
@ -19,5 +19,11 @@ var XmlTest = new TestCase("mode.XmlTest", {
|
|||
var range = new ace.Range(0, 3, 1, 1);
|
||||
var comment = this.mode.toggleCommentLines("start", doc, range);
|
||||
assertEquals([" abc", "cde", "fg"].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
"test: next line indent should be the same as the current line indent" : function() {
|
||||
assertEquals(" ", this.mode.getNextLineIndent("start", " abc"));
|
||||
assertEquals("", this.mode.getNextLineIndent("start", "abc"));
|
||||
assertEquals("\t", this.mode.getNextLineIndent("start", "\tabc"));
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue