From be133eaab2fb804ea5f2080a1648277c17e6775a Mon Sep 17 00:00:00 2001 From: gregorni Date: Wed, 27 Sep 2023 16:35:33 +0200 Subject: [PATCH] Formatter: Make tests pass --- blueprintcompiler/formatter.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/blueprintcompiler/formatter.py b/blueprintcompiler/formatter.py index 07987f0..35c3cb6 100644 --- a/blueprintcompiler/formatter.py +++ b/blueprintcompiler/formatter.py @@ -140,8 +140,8 @@ class Format: another_newline(True) commit_current_line( LineType.BLOCK_OPEN, - # newlines=2 if prev_line_type in [LineType.CHILD_TYPE, LineType.COMMENT] - # or prev_line_type == LineType.BLOCK_OPEN else 1 + newlines=2 if prev_line_type in [LineType.CHILD_TYPE, LineType.COMMENT] + or prev_line_type == LineType.BLOCK_OPEN else 1 ) elif str_item == "]" and is_child_type: @@ -165,16 +165,13 @@ class Format: elif str_item == ";": if len(current_line) == 1: - newlines=0 + newlines = 0 elif prev_line_type == LineType.BLOCK_CLOSE: - newlines=2 + newlines = 2 else: - newlines=1 + newlines = 1 - commit_current_line( - indent_decrease=True, - newlines=newlines - ) + commit_current_line(indent_decrease=True, newlines=newlines) elif item.type == TokenType.COMMENT: commit_current_line(LineType.COMMENT)