clang-format: [JS] Fix indentation in dict literals.

Before:
  return {
    'finish':
        //
        a
        };

After:
  return {
    'finish':
        //
        a
  };

llvm-svn: 217235
This commit is contained in:
Daniel Jasper 2014-09-05 08:29:31 +00:00
parent 634c355e35
commit 97bfb7b1ba
2 changed files with 11 additions and 2 deletions

View File

@ -1110,12 +1110,16 @@ private:
/// and other tokens that we treat like binary operators.
int getCurrentPrecedence() {
if (Current) {
const FormatToken *NextNonComment = Current->getNextNonComment();
if (Current->Type == TT_ConditionalExpr)
return prec::Conditional;
else if (NextNonComment && NextNonComment->is(tok::colon) &&
NextNonComment->Type == TT_DictLiteral)
return prec::Comma;
else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon ||
Current->Type == TT_SelectorName ||
(Current->is(tok::comment) && Current->getNextNonComment() &&
Current->getNextNonComment()->Type == TT_SelectorName))
(Current->is(tok::comment) && NextNonComment &&
NextNonComment->Type == TT_SelectorName))
return 0;
else if (Current->Type == TT_RangeBasedForLoopColon)
return prec::Comma;

View File

@ -123,6 +123,11 @@ TEST_F(FormatTestJS, ContainerLiterals) {
" // comment for tasks\n"
" tasks: false\n"
"};");
verifyFormat("return {\n"
" 'finish':\n"
" //\n"
" a\n"
"};");
}
TEST_F(FormatTestJS, SpacesInContainerLiterals) {