let Shift+Enter to insert two spaces and a new line

This commit is contained in:
Le Tan 2017-05-22 22:46:24 +08:00
parent 58bc995924
commit de4e5fef8e

View File

@ -741,6 +741,17 @@ bool VMdEditOperations::handleKeyReturn(QKeyEvent *p_event)
if (p_event->modifiers() & Qt::ControlModifier) {
m_autoIndentPos = -1;
return false;
} else if (p_event->modifiers() & Qt::ShiftModifier) {
// Insert two spaces and a new line.
m_autoIndentPos = -1;
QTextCursor cursor = m_editor->textCursor();
cursor.beginEditBlock();
cursor.removeSelectedText();
cursor.insertText(" ");
cursor.endEditBlock();
// Let remaining logics handle inserting the new block.
}
// See if we need to cancel auto indent.
@ -783,6 +794,7 @@ bool VMdEditOperations::handleKeyReturn(QKeyEvent *p_event)
m_autoIndentPos = m_editor->textCursor().position();
}
}
return handled;
}