forked from OSchip/llvm-project
clang-format: [JS] Fix indentation in dict literals.
Before: return { 'finish': // a }; After: return { 'finish': // a }; llvm-svn: 217235
This commit is contained in:
parent
634c355e35
commit
97bfb7b1ba
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue