Assume the position is at the end when the offset has no last part

We get an NPE when the user cuts their entire message, and this fixes it.
pull/21833/head
Travis Ralston 2020-01-15 21:05:00 -07:00
parent b137cd21d3
commit 1b4ab856c9
1 changed files with 1 additions and 1 deletions

View File

@ -117,7 +117,7 @@ export default class DocumentPosition {
}
offset += this.offset;
const lastPart = model.parts[this.index];
const atEnd = offset >= lastPart.text.length;
const atEnd = !lastPart || offset >= lastPart.text.length; // if no last part, we're at the end
return new DocumentOffset(offset, atEnd);
}