diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-07-06 13:54:21 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-07-06 13:54:21 +0200 |
commit | bf7613d2e7bad2fb6db6570a4211c673deadb19a (patch) | |
tree | 9200e7bd26b5eb45b60ea4becb44aea630ded6d8 /src/plugins/cpptools/cppcodeformatter.cpp | |
parent | 8dbbf9be92f834b021183ac0ad7c851b86e288ce (diff) | |
download | qt-creator-bf7613d2e7bad2fb6db6570a4211c673deadb19a.tar.gz |
C++ indenter: Add special case rule for indenting enums.
So you now get
enum A { a = 2,
b = 3,
};
Diffstat (limited to 'src/plugins/cpptools/cppcodeformatter.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodeformatter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index 0eb40bf4e9..582293ff10 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -937,18 +937,23 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd case class_open: case enum_open: - case defun_open: + case defun_open: { // undo the continuation indent of the parent *savedIndentDepth = parentState.savedIndentDepth; - if (firstToken) + bool followedByData = (!lastToken && !tokenAt(tokenIndex() + 1).isComment()); + if (firstToken || followedByData) *savedIndentDepth = tokenPosition; *indentDepth = *savedIndentDepth; - if (m_indentDeclarationMembers) + if (followedByData) { + *indentDepth = column(tokenAt(tokenIndex() + 1).begin()); + } else if (m_indentDeclarationMembers) { *indentDepth += m_indentSize; + } break; + } case substatement_open: if (firstToken) { |