Don't use $lines in setValue and $clipPosition to

make subclassing easier
This commit is contained in:
Fabian Jakobs 2011-01-19 12:29:53 +01:00
commit 81a742e2f1

View file

@ -56,7 +56,8 @@ var Document = function(text) {
oop.implement(this, EventEmitter);
this.setValue = function(text) {
this.remove(new Range(0, 0, this.$lines.length, this.getLine(this.$lines.length-1).length));
var len = this.getLength();
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
this.insertLines(0, this.$split(text));
};
@ -151,7 +152,7 @@ var Document = function(text) {
};
this.$clipPosition = function(position) {
var length = this.$lines.length;
var length = this.getLength();
if (position.row >= length) {
position.row = Math.max(0, length - 1);
position.column = this.getLine(length-1).length;