clang-format: [JS] Fix bug in regex literal parsing.

The lexer wasn't properly reset leading to unexpected deletions.

llvm-svn: 241262
This commit is contained in:
Daniel Jasper 2015-07-02 14:01:34 +00:00
parent 3d2ba47a90
commit 55c384e039
2 changed files with 2 additions and 0 deletions

View File

@ -1227,6 +1227,7 @@ private:
getFormattingLangOpts(Style), Buffer.begin(),
Buffer.begin() + Offset, Buffer.end()));
Lex->SetKeepWhitespaceMode(true);
TrailingWhitespace = 0;
}
};

View File

@ -631,6 +631,7 @@ TEST_F(FormatTestJS, RegexLiteralSpecialCharacters) {
"var x = 0;",
format("var regex = /\\/*/;\n"
"var x=0;"));
EXPECT_EQ("var x = /a\\//;", format("var x = /a\\// \n;"));
verifyFormat("var regex = /\"/;", getGoogleJSStyleWithColumns(16));
verifyFormat("var regex =\n"
" /\"/;",