Formatter: Close empty objects on same line

This commit is contained in:
Gregor Niehl 2023-11-04 13:51:22 +01:00 committed by James Westman
parent 3c424d03a4
commit 703e2626dd
2 changed files with 6 additions and 6 deletions

View file

@ -153,6 +153,9 @@ class Formatter:
current_line = current_line[:-1] current_line = current_line[:-1]
commit_current_line() commit_current_line()
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 indent_levels -= 1
commit_current_line(LineType.BLOCK_CLOSE, True) commit_current_line(LineType.BLOCK_CLOSE, True)

View file

@ -20,12 +20,10 @@ template $MyTemplate: Label {
flags: a | b; flags: a | b;
[child] [child]
Label { Label {}
}
[child] [child]
Label label2 { Label label2 {}
}
// Single line comment. // Single line comment.
@ -40,8 +38,7 @@ template $MyTemplate: Label {
Dialog { Dialog {
[action response=ok] [action response=ok]
$MyButton { $MyButton {}
}
} }
menu menu { menu menu {