forked from OSchip/llvm-project
clang-format: Don't generate unnecessary replacements for \r\n line endings.
Patch by Mathieu Champlon. Thank you. llvm-svn: 239900
This commit is contained in:
parent
6a1e0eb27d
commit
d6e618892f
|
@ -345,7 +345,7 @@ void BreakableBlockComment::adjustWhitespace(unsigned LineIndex,
|
|||
// Calculate the start of the non-whitespace text in the current line.
|
||||
size_t StartOfLine = Lines[LineIndex].find_first_not_of(Blanks);
|
||||
if (StartOfLine == StringRef::npos)
|
||||
StartOfLine = Lines[LineIndex].size();
|
||||
StartOfLine = Lines[LineIndex].rtrim("\r\n").size();
|
||||
|
||||
StringRef Whitespace = Lines[LineIndex].substr(0, StartOfLine);
|
||||
// Adjust Lines to only contain relevant text.
|
||||
|
|
|
@ -146,6 +146,13 @@ TEST_F(FormatTest, OnlyGeneratesNecessaryReplacements) {
|
|||
" f();\n"
|
||||
"}"));
|
||||
EXPECT_EQ(0, ReplacementCount);
|
||||
EXPECT_EQ("/*\r\n"
|
||||
"\r\n"
|
||||
"*/\r\n",
|
||||
format("/*\r\n"
|
||||
"\r\n"
|
||||
"*/\r\n"));
|
||||
EXPECT_EQ(0, ReplacementCount);
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, RemovesEmptyLines) {
|
||||
|
|
Loading…
Reference in New Issue