Editor: Simplify cursor in snippet check.

Change-Id: I7f2c6a411122d83a118b22814acf50bb0b66d95e
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
David Schulz
2016-04-05 14:33:25 +02:00
parent 1ae483fc83
commit 6bad4bf5c6

View File

@@ -2387,6 +2387,7 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
// because AltGr maps to Alt + Ctrl // because AltGr maps to Alt + Ctrl
QTextCursor cursor = textCursor(); QTextCursor cursor = textCursor();
const QString &autoText = d->m_autoCompleter->autoComplete(cursor, eventText); const QString &autoText = d->m_autoCompleter->autoComplete(cursor, eventText);
const bool cursorWithinSnippet = d->snippetCheckCursor(cursor);
QChar electricChar; QChar electricChar;
if (d->m_document->typingSettings().m_autoIndent) { if (d->m_document->typingSettings().m_autoIndent) {
@@ -2398,10 +2399,6 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e)
} }
} }
bool cursorWithinSnippet = false;
if (d->m_snippetOverlay->isVisible())
cursorWithinSnippet = d->snippetCheckCursor(cursor);
bool doEditBlock = !electricChar.isNull() || !autoText.isEmpty() || cursorWithinSnippet; bool doEditBlock = !electricChar.isNull() || !autoText.isEmpty() || cursorWithinSnippet;
if (doEditBlock) if (doEditBlock)
cursor.beginEditBlock(); cursor.beginEditBlock();