diff --git a/lib/ace/document.js b/lib/ace/document.js index 985e2091..bb25eeb6 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -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;