Skip to content

Commit f9fd365

Browse files
author
steveluc
committed
Added logic to handle requests for changes past the end of the buffer.
1 parent 42bc64b commit f9fd365

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/server/editorServices.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ module ts.server {
12591259

12601260
getText(rangeStart: number, rangeLength: number) {
12611261
var accum = "";
1262-
if (rangeLength > 0) {
1262+
if ((rangeLength > 0) && (rangeStart < this.root.charCount())) {
12631263
this.walk(rangeStart, rangeLength, {
12641264
goSubtree: true,
12651265
done: false,
@@ -1322,14 +1322,14 @@ module ts.server {
13221322
}
13231323
else if (pos >= this.root.charCount()) {
13241324
// insert at end
1325-
var endString = this.getText(pos - 1, 1);
1325+
pos = this.root.charCount() - 1;
1326+
var endString = this.getText(pos, 1);
13261327
if (newText) {
13271328
newText = endString + newText;
13281329
}
13291330
else {
13301331
newText = endString;
13311332
}
1332-
pos = pos - 1;
13331333
deleteLength = 0;
13341334
walker.suppressTrailingText = true;
13351335
}

0 commit comments

Comments
 (0)