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 @@ -63,8 +63,14 @@ void verifyFormat(llvm::StringRef Code, const FormatStyle &Style = getLLVMStyle()) { - EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable"; - EXPECT_EQ(Code.str(), format(test::messUp(Code), Style)); + verifyFormat(Code, Code, Style); + } + + void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code, + const FormatStyle &Style = getLLVMStyle()) { + EXPECT_EQ(Expected.str(), format(Expected, Style)) + << "Expected code is not stable"; + EXPECT_EQ(Expected.str(), format(test::messUp(Code), Style)); } void verifyGoogleFormat(llvm::StringRef Code) { @@ -715,6 +721,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) {