This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG1116ed2beb1c: [clang-format] Correctly count a tab's width in a comment (authored by HazardyKnusperkeks).
Changed prior to commit: https://reviews.llvm.org/D138402?vs=480597&id=539471#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D138402/new/ https://reviews.llvm.org/D138402 Files: clang/lib/Format/BreakableToken.cpp clang/unittests/Format/FormatTestComments.cpp Index: clang/unittests/Format/FormatTestComments.cpp =================================================================== --- clang/unittests/Format/FormatTestComments.cpp +++ clang/unittests/Format/FormatTestComments.cpp @@ -652,6 +652,11 @@ "//: one line", format("//: A comment that doesn't fit on one line", getLLVMStyleWithColumns(20))); + + verifyFormat( + "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth()\n" + "//* 0.2)", + "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth() * 0.2)"); } TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) { Index: clang/lib/Format/BreakableToken.cpp =================================================================== --- clang/lib/Format/BreakableToken.cpp +++ clang/lib/Format/BreakableToken.cpp @@ -82,9 +82,9 @@ NumChars < MaxSplit && MaxSplitBytes < Text.size();) { unsigned BytesInChar = encoding::getCodePointNumBytes(Text[MaxSplitBytes], Encoding); - NumChars += - encoding::columnWidthWithTabs(Text.substr(MaxSplitBytes, BytesInChar), - ContentStartColumn, TabWidth, Encoding); + NumChars += encoding::columnWidthWithTabs( + Text.substr(MaxSplitBytes, BytesInChar), ContentStartColumn + NumChars, + TabWidth, Encoding); MaxSplitBytes += BytesInChar; }
Index: clang/unittests/Format/FormatTestComments.cpp =================================================================== --- clang/unittests/Format/FormatTestComments.cpp +++ clang/unittests/Format/FormatTestComments.cpp @@ -652,6 +652,11 @@ "//: one line", format("//: A comment that doesn't fit on one line", getLLVMStyleWithColumns(20))); + + verifyFormat( + "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth()\n" + "//* 0.2)", + "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth() * 0.2)"); } TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) { Index: clang/lib/Format/BreakableToken.cpp =================================================================== --- clang/lib/Format/BreakableToken.cpp +++ clang/lib/Format/BreakableToken.cpp @@ -82,9 +82,9 @@ NumChars < MaxSplit && MaxSplitBytes < Text.size();) { unsigned BytesInChar = encoding::getCodePointNumBytes(Text[MaxSplitBytes], Encoding); - NumChars += - encoding::columnWidthWithTabs(Text.substr(MaxSplitBytes, BytesInChar), - ContentStartColumn, TabWidth, Encoding); + NumChars += encoding::columnWidthWithTabs( + Text.substr(MaxSplitBytes, BytesInChar), ContentStartColumn + NumChars, + TabWidth, Encoding); MaxSplitBytes += BytesInChar; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits