Index: lib/Format/ContinuationIndenter.cpp =================================================================== --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -991,7 +991,7 @@ if (Current.isOneOf(tok::l_brace, TT_ArrayInitializerLSquare)) { if (Current.opensBlockOrBlockTypeList(Style)) { NewIndent = State.Stack.back().NestedBlockIndent + Style.IndentWidth; - NewIndent = std::min(State.Column + 2, NewIndent); + NewIndent = std::min(State.Column + Style.IndentWidth, NewIndent); } else { NewIndent = State.Stack.back().LastSpace + Style.ContinuationIndentWidth; } Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -287,6 +287,31 @@ "};"); } +TEST_F(FormatTestJS, ContainerLiteralsIndentWidth) { + FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript); + Style.IndentWidth = 4; + + verifyFormat("return [\n" + " {\n" + " a: 1,\n" + " },\n" + " {\n" + " b: 2,\n" + " },\n" + "];", + Style); + verifyFormat("return {\n" + " nested: {\n" + " values: {\n" + " indent: [\n" + " right,\n" + " ],\n" + " },\n" + " },\n" + "};", + Style); +} + TEST_F(FormatTestJS, MethodsInObjectLiterals) { verifyFormat("var o = {\n" " value: 'test',\n"