From 1b4ab856c9b9fdfe79a2e97685fe6816db68bf9a Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 15 Jan 2020 21:05:00 -0700 Subject: [PATCH] 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. --- src/editor/position.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor/position.js b/src/editor/position.js index 4693f629998..726377ef483 100644 --- a/src/editor/position.js +++ b/src/editor/position.js @@ -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); }