Made several changes to make ACE work with Concorde
This commit is contained in:
parent
01109b3630
commit
3d1469e330
3 changed files with 59 additions and 41 deletions
|
|
@ -67,7 +67,7 @@ var Document = function(text) {
|
|||
};
|
||||
|
||||
this.getValue = function() {
|
||||
return this.$lines.join(this.getNewLineCharacter());
|
||||
return this.getAllLines().join(this.getNewLineCharacter());
|
||||
};
|
||||
|
||||
// check for IE split bug
|
||||
|
|
@ -123,11 +123,11 @@ var Document = function(text) {
|
|||
* Get a verbatim copy of the given line as it is in the document
|
||||
*/
|
||||
this.getLine = function(row) {
|
||||
return this.$lines[row] || "";
|
||||
return this.getLines(row, row + 1)[0] || "";
|
||||
};
|
||||
|
||||
this.getLines = function(firstRow, lastRow) {
|
||||
return this.$lines.slice(firstRow, lastRow+1);
|
||||
return this.$lines.slice(firstRow, lastRow + 1);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -135,7 +135,7 @@ var Document = function(text) {
|
|||
* should not modify this array!
|
||||
*/
|
||||
this.getAllLines = function() {
|
||||
return this.$lines;
|
||||
return this.getLines(0, this.getLength());
|
||||
};
|
||||
|
||||
this.getLength = function() {
|
||||
|
|
@ -183,14 +183,29 @@ var Document = function(text) {
|
|||
var end = this.insertInLine(position, text);
|
||||
}
|
||||
else {
|
||||
var end = this.insertInLine(position, newLines[0]);
|
||||
this.insertNewLine(end);
|
||||
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]);
|
||||
if (newLines[0].length > 0) {
|
||||
var end = this.insertInLine(position, newLines[0]);
|
||||
this.insertNewLine(end);
|
||||
}
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
|
@ -278,7 +293,7 @@ var Document = function(text) {
|
|||
this.removeLines(firstFullRow, lastFullRow);
|
||||
|
||||
if (firstFullRow != firstRow) {
|
||||
this.removeInLine(firstRow, range.start.column, this.$lines[firstRow].length);
|
||||
this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
|
||||
this.removeNewLine(range.start.row);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue