diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2010-07-08 08:48:36 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2010-07-08 08:48:36 +0200 |
commit | 486b23b8ef1df404c026514b93f073163885d324 (patch) | |
tree | 048ee5fd67a7c4a5928fa81ef7ee62de98edb243 /src/plugins/cpptools/cppcodeformatter.cpp | |
parent | 6078b36c9cd4b63faa3d5ae4b59a19cae84bfc47 (diff) | |
download | qt-creator-486b23b8ef1df404c026514b93f073163885d324.tar.gz |
C++ indenter: Don't add continuation indent after function return type.
Task-number: QTCREATORBUG-1816
Diffstat (limited to 'src/plugins/cpptools/cppcodeformatter.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodeformatter.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp index 1c84bae4b8..ac4d94faf9 100644 --- a/src/plugins/cpptools/cppcodeformatter.cpp +++ b/src/plugins/cpptools/cppcodeformatter.cpp @@ -932,7 +932,6 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd case statement_with_condition: case for_statement: case switch_statement: - case declaration_start: case if_statement: case return_statement: if (firstToken) @@ -940,6 +939,19 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd *indentDepth = *savedIndentDepth + 2*m_indentSize; break; + case declaration_start: + if (firstToken) + *savedIndentDepth = tokenPosition; + // continuation indent in function bodies only, to not indent + // after the return type in "void\nfoo() {}" + for (int i = 0; state(i).type != topmost_intro; ++i) { + if (state(i).type == defun_open) { + *indentDepth = *savedIndentDepth + 2*m_indentSize; + break; + } + } + break; + case arglist_open: case condition_paren_open: if (!lastToken) |