auto indent fix

This commit is contained in:
Fabian Jakobs 2010-12-16 15:06:40 +01:00
commit 80a11082b1
2 changed files with 10 additions and 1 deletions

View file

@ -426,7 +426,7 @@ var Editor =function(renderer, doc) {
this.bgTokenizer.getState(cursor.row, function (lineState) {
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(cursor.row), text);
var line = _self.doc.getLine(cursor.row),
lineIndent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
lineIndent = _self.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), _self.doc.getTabString());
var end = _self.doc.insert(cursor, text);
/* TODO: This shortcut is somehow broken

View file

@ -133,6 +133,15 @@ var Test = {
editor.indent();
assert.equal(["a12345", " b12345", "c12345"].join("\n"), doc.toString());
},
"test: no auto indent if cursor is before the {" : function() {
var doc = new Document("{", new JavaScriptMode());
var editor = new Editor(new MockRenderer(), doc);
editor.moveCursorTo(0, 0);
editor.onTextInput("\n");
assert.equal(["", "{"].join("\n"), doc.toString());
},
"test: outdent block" : function() {
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));