From f9b23e69b63cbbeed8eeb605c0dc491002a4c23b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 14 Nov 2016 13:39:50 +0200 Subject: [PATCH] Check if blocks need braces at formatting time --- source/programcompiler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/programcompiler.cpp b/source/programcompiler.cpp index 2428ab79..a730f743 100644 --- a/source/programcompiler.cpp +++ b/source/programcompiler.cpp @@ -245,7 +245,8 @@ void ProgramCompiler::Formatter::visit(Block &block) --else_if; unsigned brace_indent = indent; - if(block.use_braces) + bool use_braces = (block.use_braces || (indent && block.body.size()!=1)); + if(use_braces) formatted += format("%s{\n", string(brace_indent*2, ' ')); SetForScope set(indent, indent+!formatted.empty()); @@ -259,7 +260,7 @@ void ProgramCompiler::Formatter::visit(Block &block) else_if = 0; } - if(block.use_braces) + if(use_braces) formatted += format("\n%s}", string(brace_indent*2, ' ')); } -- 2.45.2