summaryrefslogtreecommitdiffstats
path: root/src/Utils
diff options
context:
space:
mode:
authorMichal Čihař <michal@cihar.com>2017-04-04 09:14:58 +0200
committerMichal Čihař <michal@cihar.com>2017-04-04 09:17:57 +0200
commit7973054aaf9baf8834515cdd0ea0522b10fe7193 (patch)
treeedc4b85d39c9d60a63b603ccf90edc84812ca762 /src/Utils
parent3fb0cf70e6817649cf50d5f40ec5ebc73e100b13 (diff)
downloadsql-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.php4
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;
}