diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp
index 76a6fe1ca71ed835b1f9d6a47dc241ba72794f24..0e11c9c047a69159a2b6b5e8c13a010ab6d78eaf 100644
--- a/src/libs/cplusplus/MatchingText.cpp
+++ b/src/libs/cplusplus/MatchingText.cpp
@@ -40,6 +40,7 @@ static bool maybeOverrideChar(const QChar &ch)
 {
     if      (ch == QLatin1Char(')'))  return true;
     else if (ch == QLatin1Char(']'))  return true;
+    else if (ch == QLatin1Char(';'))  return true;
     else if (ch == QLatin1Char('"'))  return true;
     else if (ch == QLatin1Char('\'')) return true;
     else                               return false;
@@ -97,8 +98,6 @@ MatchingText::MatchingText()
 QString MatchingText::insertMatchingBrace(const QTextCursor &cursor, const QString &textToProcess,
                                           const QChar &la, int *skippedChars) const
 {
-    *skippedChars = 0;
-
     QTextCursor tc = cursor;
     QString text = textToProcess;
 
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 083f67187158fc4eee68bb22464dee59e97967b3..276e5b24eb145f6782ea184fafb8463edb042f5c 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -1270,16 +1270,25 @@ bool CPPEditor::isElectricCharacter(const QChar &ch) const
 }
 
 #if 1
-QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &text) const
+QString CPPEditor::autoComplete(QTextCursor &cursor, const QString &textToInsert) const
 {
+    bool checkBlockEnd = m_allowSkippingOfBlockEnd;
+    m_allowSkippingOfBlockEnd = false;
+
     if (!contextAllowsAutoParentheses(cursor))
         return QString();
 
-    QChar lookAhead = characterAt(cursor.selectionEnd());
+    QString text = textToInsert;
+    const QChar lookAhead = characterAt(cursor.selectionEnd());
 
     QString autoText;
     int skippedChars = 0;
 
+    if (checkBlockEnd && (lookAhead == QChar::ParagraphSeparator && (! text.isEmpty() && text.at(0) == QLatin1Char('}')))) {
+        skippedChars = 2;
+        text = text.mid(1);
+    }
+
     MatchingText matchingText;
     autoText = matchingText.insertMatchingBrace(cursor, text, lookAhead, &skippedChars);