diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index 6ffa584711..15a7c29e3a 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -210,8 +210,8 @@ export default class BasicMessageEditor extends React.Component { const selectedParts = range.parts.map(p => p.serialize()); event.clipboardData.setData("application/x-riot-composer", JSON.stringify(selectedParts)); if (type === "cut") { - selection.deleteFromDocument(); - range.replace([]); + // Remove the text, updating the model as appropriate + replaceRangeAndMoveCaret(range, []); } event.preventDefault(); } diff --git a/src/editor/position.js b/src/editor/position.js index 4693f62999..726377ef48 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); }