Created
April 3, 2018 07:14
-
-
Save Srekel/59805f494d1b75ea142ef8796d1db7fb to your computer and use it in GitHub Desktop.
Clang format feature: AligningIgnoresBlankLines (WIP, doesn't work perfectly)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: include/clang/Format/Format.h | |
| =================================================================== | |
| --- include/clang/Format/Format.h (revision 304556) | |
| +++ include/clang/Format/Format.h (working copy) | |
| @@ -98,6 +98,8 @@ | |
| /// \endcode | |
| bool AlignConsecutiveDeclarations; | |
| + bool AligningIgnoresBlankLines; | |
| + | |
| /// \brief Different styles for aligning escaped newlines. | |
| enum EscapedNewlineAlignmentStyle { | |
| /// \brief Don't align escaped newlines. | |
| Index: lib/Format/WhitespaceManager.cpp | |
| =================================================================== | |
| --- lib/Format/WhitespaceManager.cpp (revision 304556) | |
| +++ lib/Format/WhitespaceManager.cpp (working copy) | |
| @@ -329,7 +329,7 @@ | |
| EndOfSequence = i; | |
| // If there is a blank line, or if the last line didn't contain any | |
| // matching token, the sequence ends here. | |
| - if (Changes[i].NewlinesBefore > 1 || !FoundMatchOnLine) | |
| + if (/*Changes[i].NewlinesBefore > 1 ||*/ !FoundMatchOnLine) | |
| AlignCurrentSequence(); | |
| FoundMatchOnLine = false; | |
| @@ -471,12 +471,12 @@ | |
| MinColumn = ChangeMinColumn; | |
| MaxColumn = ChangeMinColumn; | |
| StartOfSequence = i; | |
| - } else if (BreakBeforeNext || Newlines > 1 || | |
| + } else if (BreakBeforeNext || /*Newlines > 1 ||*/ | |
| (ChangeMinColumn > MaxColumn || ChangeMaxColumn < MinColumn) || | |
| // Break the comment sequence if the previous line did not end | |
| // in a trailing comment. | |
| - (Changes[i].NewlinesBefore == 1 && i > 0 && | |
| - !Changes[i - 1].IsTrailingComment) || | |
| + (Changes[i].NewlinesBefore == 1 && i > 0 && | |
| + !Changes[i - 1].IsTrailingComment) || | |
| WasAlignedWithStartOfNextLine) { | |
| alignTrailingComments(StartOfSequence, i, MinColumn); | |
| MinColumn = ChangeMinColumn; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment