Added the helper class MatchingText and use it to automagically insert text for curly braces.

This commit is contained in:
Roberto Raggi
2009-09-17 15:44:54 +02:00
parent 97df3b6cca
commit dfa6be721d
8 changed files with 273 additions and 58 deletions

View File

@@ -52,6 +52,7 @@
#include <cplusplus/SimpleLexer.h>
#include <cplusplus/TokenUnderCursor.h>
#include <cplusplus/TypeOfExpression.h>
#include <cplusplus/MatchingText.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <coreplugin/icore.h>
@@ -1374,7 +1375,11 @@ int CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
if (braceDepth > 0) { // we do have an extra brace, let's close it
int pos = cursor.position();
cursor.insertText(QLatin1String("}"));
MatchingText matchingText;
const QString textToInsert = matchingText.insertParagraphSeparator(cursor);
cursor.insertText(textToInsert);
cursor.setPosition(pos);
const TabSettings &ts = tabSettings();
if (ts.m_autoIndent) {