first support for auto indent
This commit is contained in:
parent
34d851b24e
commit
e9fe18f657
8 changed files with 129 additions and 25 deletions
|
|
@ -44,6 +44,8 @@ var TextEditTest = TestCase("TextEditTest",
|
|||
assertEquals(["a12345", " b12345", " c12345"].join("\n"),
|
||||
doc.toString());
|
||||
|
||||
assertPosition(2, 7, editor.getCursorPosition());
|
||||
|
||||
var selection = editor.getSelectionRange();
|
||||
assertPosition(1, 7, selection.start);
|
||||
assertPosition(2, 7, selection.end);
|
||||
|
|
@ -61,6 +63,8 @@ var TextEditTest = TestCase("TextEditTest",
|
|||
assertEquals([" a12345", "b12345", " c12345"].join("\n"),
|
||||
doc.toString());
|
||||
|
||||
assertPosition(2, 1, editor.getCursorPosition());
|
||||
|
||||
var selection = editor.getSelectionRange();
|
||||
assertPosition(0, 1, selection.start);
|
||||
assertPosition(2, 1, selection.end);
|
||||
|
|
@ -75,6 +79,17 @@ var TextEditTest = TestCase("TextEditTest",
|
|||
assertPosition(2, 1, selection.end);
|
||||
},
|
||||
|
||||
"test: outent without a selection should update cursor" : function() {
|
||||
var doc = new ace.TextDocument(" 12");
|
||||
var editor = new ace.Editor(new MockRenderer(), doc);
|
||||
|
||||
editor.moveCursorTo(0, 3);
|
||||
editor.blockOutdent(" ");
|
||||
|
||||
assertEquals(" 12", doc.toString());
|
||||
assertPosition(0, 1, editor.getCursorPosition());
|
||||
},
|
||||
|
||||
"test: comment lines should perserve selection" : function() {
|
||||
var doc = new ace.TextDocument([" abc", "cde"].join("\n"));
|
||||
var editor = new ace.Editor(new MockRenderer(), doc, new ace.mode.JavaScript());
|
||||
|
|
|
|||
|
|
@ -47,5 +47,35 @@ var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
|||
|
||||
var comment = this.mode.toggleCommentLines(doc, range);
|
||||
assertEquals(["//// abc", "////cde", "//fg"].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
"test: auto indent after opening brace" : function() {
|
||||
var doc = new ace.TextDocument(["if () {"].join("\n"));
|
||||
var editor = new ace.Editor(new MockRenderer(), doc, this.mode);
|
||||
|
||||
editor.navigateLineEnd();
|
||||
editor.onTextInput("\n");
|
||||
|
||||
assertEquals(["if () {", editor.getTabString()].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
"test: no auto indent after opening brace in multi line comment" : function() {
|
||||
var doc = new ace.TextDocument(["/*if () {"].join("\n"));
|
||||
var editor = new ace.Editor(new MockRenderer(), doc, this.mode);
|
||||
|
||||
editor.navigateLineEnd();
|
||||
editor.onTextInput("\n");
|
||||
|
||||
assertEquals(["/*if () {", ""].join("\n"), doc.toString());
|
||||
},
|
||||
|
||||
"test: no auto indent should add to existing indent" : function() {
|
||||
var doc = new ace.TextDocument([" if () {"].join("\n"));
|
||||
var editor = new ace.Editor(new MockRenderer(), doc, this.mode);
|
||||
|
||||
editor.navigateLineEnd();
|
||||
editor.onTextInput("\n");
|
||||
|
||||
assertEquals([" if () {", " " + editor.getTabString()].join("\n"), doc.toString());
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue