Merge remote branch 'jcheng5/tmp-blankline-alternate-fix'

Conflicts:
	lib/ace/document.js
This commit is contained in:
Fabian Jakobs 2011-02-17 10:56:54 +01:00
commit 0cbaa4cbd9

View file

@ -174,46 +174,17 @@ var Document = function(text) {
if (this.getLength() <= 1)
this.$detectNewLine(text);
var newLines = this.$split(text);
var lines = this.$split(text);
var firstLine = lines.splice(0, 1)[0];
var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
if (this.isNewLine(text)) {
var end = this.insertNewLine(position);
position = this.insertInLine(position, firstLine);
if (lastLine !== null) {
position = this.insertNewLine(position); // terminate first line
position = this.insertLines(position.row, lines);
position = this.insertInLine(position, lastLine || "");
}
else if (newLines.length == 1) {
var end = this.insertInLine(position, text);
}
else {
// Insert the first line
if (newLines[0].length > 0) {
var end = this.insertInLine(position, newLines[0]);
this.insertNewLine(end);
}
else {
this.insertNewLine(position);
}
// Now insert remaining lines
// If we are inserting at the end of the document, we don't need to
// use insertInLine (concorde depends on this optimization!)
if (position.row + 1 == this.getLength()) {
this.insertLines(position.row + 1,
newLines.slice(1, newLines.length));
var end = {
row: position.row + newLines.length - 1,
column: position.column + newLines[newLines.length - 1].length
};
} else {
if (newLines.length > 2)
this.insertLines(position.row + 1,
newLines.slice(1, newLines.length - 1));
var end = this.insertInLine({
row: position.row + newLines.length - 1,
column: 0
}, newLines[newLines.length - 1]);
}
}
return end;
return position;
};
this.insertLines = function(row, lines) {