diff --git a/blueprintcompiler/formatter.py b/blueprintcompiler/formatter.py index 0f09679..c907adb 100644 --- a/blueprintcompiler/formatter.py +++ b/blueprintcompiler/formatter.py @@ -153,6 +153,9 @@ class Formatter: current_line = current_line[:-1] commit_current_line() current_line = "]" + elif str(last_not_whitespace) in OPENING_TOKENS: + end_str = end_str.strip() + commit_current_line(LineType.BLOCK_CLOSE, True, 0) indent_levels -= 1 commit_current_line(LineType.BLOCK_CLOSE, True) diff --git a/tests/formatting/correct1.blp b/tests/formatting/correct1.blp index 2cb4f23..42d55fa 100644 --- a/tests/formatting/correct1.blp +++ b/tests/formatting/correct1.blp @@ -20,12 +20,10 @@ template $MyTemplate: Label { flags: a | b; [child] - Label { - } + Label {} [child] - Label label2 { - } + Label label2 {} // Single line comment. @@ -40,8 +38,7 @@ template $MyTemplate: Label { Dialog { [action response=ok] - $MyButton { - } + $MyButton {} } menu menu {