Skip to content

Commit

Permalink
Fix aligning of '<<' in C++
Browse files Browse the repository at this point in the history
From: Oleg Smolsky
  • Loading branch information
bengardner committed Mar 28, 2012
1 parent 9fa0183 commit 5ff3643
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/align.cpp
Expand Up @@ -1777,6 +1777,20 @@ static void align_left_shift(void)
}
else if (as.m_aligned.Empty())
{
/* check if the first one is actually on a blank line and then
* indent it. Eg:
*
* cout
* << "something";
*/
chunk_t *prev = chunk_get_prev(pc);
if (prev && chunk_is_newline(prev))
{
indent_to_column(pc, pc->column_indent + cpd.settings[UO_indent_columns].n);
pc->column_indent = pc->column;
pc->flags |= PCF_DONT_INDENT;
}

/* first one can be anywhere */
as.Add(pc);
start = pc;
Expand All @@ -1787,6 +1801,22 @@ static void align_left_shift(void)
as.Add(pc);
}
}
else if (!as.m_aligned.Empty())
{
/* check if the given statement is on a line of its own, immediately following <<
* and then it. Eg:
*
* cout <<
* "something";
*/
chunk_t *prev = chunk_get_prev(pc);
if (prev && chunk_is_newline(prev))
{
indent_to_column(pc, pc->column_indent + cpd.settings[UO_indent_columns].n);
pc->column_indent = pc->column;
pc->flags |= PCF_DONT_INDENT;
}
}

pc = chunk_get_next(pc);
}
Expand Down

0 comments on commit 5ff3643

Please sign in to comment.