Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -803,13 +803,14 @@ analyze(TokenAnnotator &Annotator, SmallVectorImpl &AnnotatedLines, FormatTokenLexer &Tokens, tooling::Replacements &Result) override { + tooling::Replacements RunResult; deriveLocalStyle(AnnotatedLines); AffectedRangeMgr.computeAffectedLines(AnnotatedLines.begin(), AnnotatedLines.end()); if (Style.Language == FormatStyle::LK_JavaScript && Style.JavaScriptQuotes != FormatStyle::JSQS_Leave) - requoteJSStringLiteral(AnnotatedLines, Result); + requoteJSStringLiteral(AnnotatedLines, RunResult); for (unsigned i = 0, e = AnnotatedLines.size(); i != e; ++i) { Annotator.calculateFormattingInformation(*AnnotatedLines[i]); @@ -826,7 +827,8 @@ UnwrappedLineFormatter(&Indenter, &Whitespaces, Style, Tokens.getKeywords(), IncompleteFormat) .format(AnnotatedLines); - return Whitespaces.generateReplacements(); + RunResult = RunResult.merge(Whitespaces.generateReplacements()); + return RunResult; } private: Index: unittests/Format/FormatTestJS.cpp =================================================================== --- unittests/Format/FormatTestJS.cpp +++ unittests/Format/FormatTestJS.cpp @@ -1318,6 +1318,13 @@ "let x = \"single\";\n"); } +TEST_F(FormatTestJS, RequoteAndIndent) { + verifyFormat("let x = someVeryLongFunctionThatGoesOnAndOn(\n" + " 'double quoted string that needs wrapping');", + "let x = someVeryLongFunctionThatGoesOnAndOn(" + "\"double quoted string that needs wrapping\");"); +} + TEST_F(FormatTestJS, RequoteStringsDouble) { FormatStyle DoubleQuotes = getGoogleStyle(FormatStyle::LK_JavaScript); DoubleQuotes.JavaScriptQuotes = FormatStyle::JSQS_Double;