Flush on writing at a modified indentation level.

This obviates the need for explicit flushes, without causing a flush in the case where indentation is modified and reset without a newline occurring.

Change-Id: Idabdc4d0b8d66e621ab25b66196239ae6bb2c7fa
diff --git a/tools/codergen/format/writer.go b/tools/codergen/format/writer.go
index fbe5215..0bd47e2 100644
--- a/tools/codergen/format/writer.go
+++ b/tools/codergen/format/writer.go
@@ -42,6 +42,7 @@
 	out       *tabwriter.Writer
 	space     bytes.Buffer
 	depth     int
+	lastDepth int
 	newline   bool
 	Indent    string
 	disabled  bool
@@ -93,6 +94,11 @@
 		default:
 			if w.newline {
 				w.newline = false
+				if w.depth != w.lastDepth {
+					// indentation is different to last real write, so flush the tabwriter
+					w.Flush()
+					w.lastDepth = w.depth
+				}
 				if w.depth > 0 {
 					w.runeBuf[0] = tabwriter.Escape
 					w.out.Write(w.runeBuf[:1])
diff --git a/tools/codergen/template/embed.go b/tools/codergen/template/embed.go
index c9e2c9d..d0357c5 100644
--- a/tools/codergen/template/embed.go
+++ b/tools/codergen/template/embed.go
@@ -243,7 +243,6 @@
       {{if not (len .Fields)}}
         Fields:║[]schema.Field{},¶
       {{else}}
-        ø
         Fields: []schema.Field{Ȧ
           {{range .Fields}}
             {Declared:║"{{.Declared}}", Type: {{Call "Go.Schema" .Type}}},¶
diff --git a/tools/codergen/template/go_binary.tmpl b/tools/codergen/template/go_binary.tmpl
index 9cea41f..5319e7b 100644
--- a/tools/codergen/template/go_binary.tmpl
+++ b/tools/codergen/template/go_binary.tmpl
@@ -86,7 +86,6 @@
       {{if not (len .Fields)}}
         Fields:║[]schema.Field{},¶
       {{else}}
-        ø
         Fields: []schema.Field{Ȧ
           {{range .Fields}}
             {Declared:║"{{.Declared}}", Type: {{Call "Go.Schema" .Type}}},¶