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 lineIndent = this.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), this.session.getTabString());
var end = this.session.insert(cursor, text); var end = this.session.insert(cursor, text);
this.moveCursorToPosition(end);
var lineState = this.bgTokenizer.getState(cursor.row); var lineState = this.bgTokenizer.getState(cursor.row);
// multi line insert // multi line insert
if (cursor.row !== end.row) { if (cursor.row !== end.row) {
@ -435,14 +437,14 @@ var Editor =function(renderer, session) {
outdent -= size; outdent -= size;
else if (line.charAt(i) == ' ') else if (line.charAt(i) == ' ')
outdent -= 1; 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); this.session.indentRows(cursor.row + 1, end.row, lineIndent);
} else { } else {
if (shouldOutdent) { if (shouldOutdent) {
this.mode.autoOutdent(lineState, this.session, cursor.row); this.mode.autoOutdent(lineState, this.session, cursor.row);
} }
} };
} }
this.onTextInput = function(text) { this.onTextInput = function(text) {