diff --git a/src/language/sql/formatter.ts b/src/language/sql/formatter.ts index 8fddf575..cdcd4f80 100644 --- a/src/language/sql/formatter.ts +++ b/src/language/sql/formatter.ts @@ -32,17 +32,17 @@ export function formatSql(textDocument: string, options: FormatOptions = {}): st currentIndent -= 4; } - if (options.spaceBetweenStatements) { - if (prevType !== statement.type) { - result.push(``); - } - } - result.push(...formatTokens(withBlocks, options).map(l => ``.padEnd(currentIndent) + l)); if (!statement.isCompoundStart()) { result[result.length-1] += `;` } + if (options.spaceBetweenStatements) { + if (prevType !== statement.type && i < statementGroup.statements.length - 1) { + result.push(``); + } + } + if (statement.isCompoundStart() || statement.isConditionStart()) { currentIndent += 4; }