Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Assume the position is at the end when the offset has no last part
Browse files Browse the repository at this point in the history
We get an NPE when the user cuts their entire message, and this fixes it.
  • Loading branch information
turt2live committed Jan 16, 2020
1 parent b137cd2 commit 1b4ab85
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/editor/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 1b4ab85

Please sign in to comment.