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

Remove all text when cutting in the composer #3848

Merged
merged 3 commits into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/views/rooms/BasicMessageComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,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();
}
Expand Down
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