Browse Source

[clang-format] Disable AlwaysBreakBeforeMultilineStrings in Google style for Objective-C 📜

Contributed by @stephanemoore.

Reviewers: benhamilton, jolesiak, djasper

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D47393

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334739 91177308-0d34-0410-b5e6-96231b3b80d8
Ben Hamilton 7 năm trước cách đây
mục cha
commit
e8a55f98df

+ 1 - 0
lib/Format/Format.cpp

@@ -823,6 +823,7 @@ FormatStyle getGoogleStyle(FormatStyle::LanguageKind Language) {
     // has been implemented.
     // has been implemented.
     GoogleStyle.BreakStringLiterals = false;
     GoogleStyle.BreakStringLiterals = false;
   } else if (Language == FormatStyle::LK_ObjC) {
   } else if (Language == FormatStyle::LK_ObjC) {
+    GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
     GoogleStyle.ColumnLimit = 100;
     GoogleStyle.ColumnLimit = 100;
   }
   }
 
 

+ 11 - 0
unittests/Format/FormatTestObjC.cpp

@@ -1218,6 +1218,17 @@ TEST_F(FormatTestObjC, BreaksCallStatementWhereSemiJustOverTheLimit) {
                "}");
                "}");
 }
 }
 
 
+TEST_F(FormatTestObjC, AlwaysBreakBeforeMultilineStrings) {
+  Style = getGoogleStyle(FormatStyle::LK_ObjC);
+  Style.ColumnLimit = 40;
+  verifyFormat("aaaa = @\"bbbb\"\n"
+               "       @\"cccc\";");
+  verifyFormat("aaaa(@\"bbbb\"\n"
+               "     @\"cccc\");");
+  verifyFormat("aaaa(qqq, @\"bbbb\"\n"
+               "          @\"cccc\");");
+}
+
 } // end namespace
 } // end namespace
 } // end namespace format
 } // end namespace format
 } // end namespace clang
 } // end namespace clang