C++ indenter: Fix 'else' indentation in GNU style.

This commit is contained in:
Christian Kamm
2010-07-06 09:44:04 +02:00
parent fbf2efa5f6
commit 793ef6a694
2 changed files with 9 additions and 0 deletions

View File

@@ -1006,6 +1006,8 @@ void QtStyleCodeFormatter::onEnter(int newState, int *indentDepth, int *savedInd
while (isBracelessState(state(outermostBraceless).type)) while (isBracelessState(state(outermostBraceless).type))
++outermostBraceless; ++outermostBraceless;
*indentDepth = state(outermostBraceless - 1).savedIndentDepth; *indentDepth = state(outermostBraceless - 1).savedIndentDepth;
// this is where the else should go, if one appears - aligned to if_statement
*savedIndentDepth = state().savedIndentDepth;
} break; } break;
case for_statement_paren_open: case for_statement_paren_open:

View File

@@ -713,6 +713,13 @@ void tst_CodeFormatter::gnuStyle()
<< Line(" {") << Line(" {")
<< Line(" fpp;") << Line(" fpp;")
<< Line(" }") << Line(" }")
<< Line(" else if (b)")
<< Line(" {")
<< Line(" fpp;")
<< Line(" }")
<< Line(" else")
<< Line(" {")
<< Line(" }")
<< Line(" if (b) {") << Line(" if (b) {")
<< Line(" fpp;") << Line(" fpp;")
<< Line(" }") << Line(" }")