Added logic to handle requests for changes past the end of the buffer.

This commit is contained in:
steveluc 2015-03-02 16:31:51 -08:00
parent 42bc64b168
commit f9fd365215

View File

@ -1259,7 +1259,7 @@ module ts.server {
getText(rangeStart: number, rangeLength: number) {
var accum = "";
if (rangeLength > 0) {
if ((rangeLength > 0) && (rangeStart < this.root.charCount())) {
this.walk(rangeStart, rangeLength, {
goSubtree: true,
done: false,
@ -1322,14 +1322,14 @@ module ts.server {
}
else if (pos >= this.root.charCount()) {
// insert at end
var endString = this.getText(pos - 1, 1);
pos = this.root.charCount() - 1;
var endString = this.getText(pos, 1);
if (newText) {
newText = endString + newText;
}
else {
newText = endString;
}
pos = pos - 1;
deleteLength = 0;
walker.suppressTrailingText = true;
}