Merge pull request #3254 from matrix-org/t3chguy/composer_history_alt_up_always

Move history with alt up/down regardless of where selection is
This commit is contained in:
Michael Telatynski 2019-07-29 17:36:14 +01:00 committed by GitHub
commit 7f2fdd4315
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1130,17 +1130,6 @@ export default class MessageComposerInput extends React.Component {
onVerticalArrow = (e, up) => {
if (e.ctrlKey || e.shiftKey || e.metaKey) return;
// selection must be collapsed
const selection = this.state.editorState.selection;
if (!selection.isCollapsed) return;
// and we must be at the edge of the document (up=start, down=end)
const document = this.state.editorState.document;
if (up) {
if (!selection.anchor.isAtStartOfNode(document)) return;
} else {
if (!selection.anchor.isAtEndOfNode(document)) return;
}
const shouldSelectHistory = e.altKey;
const shouldEditLastMessage = !e.altKey && up && !RoomViewStore.getQuotingEvent();
@ -1152,6 +1141,17 @@ export default class MessageComposerInput extends React.Component {
e.preventDefault();
}
} else if (shouldEditLastMessage) {
// selection must be collapsed
const selection = this.state.editorState.selection;
if (!selection.isCollapsed) return;
// and we must be at the edge of the document (up=start, down=end)
const document = this.state.editorState.document;
if (up) {
if (!selection.anchor.isAtStartOfNode(document)) return;
} else {
if (!selection.anchor.isAtEndOfNode(document)) return;
}
const editEvent = findEditableEvent(this.props.room, false);
if (editEvent) {
// We're selecting history, so prevent the key event from doing anything else