From de4e5fef8e482cc5909e70a0fe41e64c6e81fe8d Mon Sep 17 00:00:00 2001 From: Le Tan Date: Mon, 22 May 2017 22:46:24 +0800 Subject: [PATCH] let Shift+Enter to insert two spaces and a new line --- src/vmdeditoperations.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/vmdeditoperations.cpp b/src/vmdeditoperations.cpp index 1316926a..698522f8 100644 --- a/src/vmdeditoperations.cpp +++ b/src/vmdeditoperations.cpp @@ -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; }