diff --git a/src/zscript/ast.cpp b/src/zscript/ast.cpp
index e11d7fb322..bc1afd3127 100644
--- a/src/zscript/ast.cpp
+++ b/src/zscript/ast.cpp
@@ -34,6 +34,7 @@ public:
 		NestDepth = Column = 0;
 		WrapWidth = 72;
 		NeedSpace = false;
+		ConsecOpens = 0;
 	}
 
 	void Open(const char *label)
@@ -43,8 +44,10 @@ public:
 		if (NeedSpace)
 		{
 			Str << ' ';
+			ConsecOpens = 0;
 		}
 		Str << '(';
+		ConsecOpens++;
 		if (label != NULL)
 		{
 			Str.AppendCStrPart(label, labellen);
@@ -66,6 +69,15 @@ public:
 		// Don't break if not needed.
 		if (Column != NestDepth)
 		{
+			if (NeedSpace)
+			{
+				ConsecOpens = 0;
+			}
+			else
+			{ // Move hanging ( characters to the new line
+				Str.Truncate(long(Str.Len() - ConsecOpens));
+				NestDepth -= ConsecOpens;
+			}
 			Str << '\n';
 			Column = NestDepth;
 			NeedSpace = false;
@@ -73,6 +85,14 @@ public:
 			{
 				Str.AppendFormat("%*s", NestDepth, "");
 			}
+			if (ConsecOpens > 0)
+			{
+				for (size_t i = 0; i < ConsecOpens; ++i)
+				{
+					Str << '(';
+				}
+				NestDepth += ConsecOpens;
+			}
 		}
 	}
 	bool CheckWrap(size_t len)
@@ -143,6 +163,7 @@ private:
 	size_t NestDepth;
 	size_t Column;
 	size_t WrapWidth;
+	size_t ConsecOpens;
 	bool NeedSpace;
 };