fix cursor positioning on enter and indent

This commit is contained in:
Fabian Jakobs 2011-02-13 16:57:33 +01:00
commit 8ac379a71e

View file

@ -405,6 +405,8 @@ var Editor =function(renderer, session) {
var lineIndent = this.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), this.session.getTabString());
var end = this.session.insert(cursor, text);
this.moveCursorToPosition(end);
var lineState = this.bgTokenizer.getState(cursor.row);
// multi line insert
if (cursor.row !== end.row) {
@ -435,14 +437,14 @@ var Editor =function(renderer, session) {
outdent -= size;
else if (line.charAt(i) == ' ')
outdent -= 1;
this.session.replace(new Range(row, 0, row, line.length), line.substr(i));
this.session.remove(new Range(row, 0, row, i));
}
this.session.indentRows(cursor.row + 1, end.row, lineIndent);
} else {
if (shouldOutdent) {
this.mode.autoOutdent(lineState, this.session, cursor.row);
}
}
};
}
this.onTextInput = function(text) {