diff options
author | Michal Čihař <michal@cihar.com> | 2017-04-04 09:14:58 +0200 |
---|---|---|
committer | Michal Čihař <michal@cihar.com> | 2017-04-04 09:17:57 +0200 |
commit | 7973054aaf9baf8834515cdd0ea0522b10fe7193 (patch) | |
tree | edc4b85d39c9d60a63b603ccf90edc84812ca762 /src/Utils | |
parent | 3fb0cf70e6817649cf50d5f40ec5ebc73e100b13 (diff) | |
download | sql-parser-7973054aaf9baf8834515cdd0ea0522b10fe7193.zip sql-parser-7973054aaf9baf8834515cdd0ea0522b10fe7193.tar.gz sql-parser-7973054aaf9baf8834515cdd0ea0522b10fe7193.tar.bz2 |
Keep linebreaks after comments
Concatenating line terminated comments will change the query.
Signed-off-by: Michal Čihař <michal@cihar.com>
Diffstat (limited to 'src/Utils')
-rw-r--r-- | src/Utils/Formatter.php | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php index c111bc7..9926db1 100644 --- a/src/Utils/Formatter.php +++ b/src/Utils/Formatter.php @@ -340,6 +340,10 @@ class Formatter $curr = $list->tokens[$list->idx]; if ($curr->type === Token::TYPE_WHITESPACE) { + // Keep linebreaks after comments + if (strpos($curr->token, "\n") !== false && $prev !== null && $prev->type === Token::TYPE_COMMENT) { + $lineEnded = true; + } // Whitespaces are skipped because the formatter adds its own. continue; } |