aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorIan Cottrell <iancottrell@google.com>2015-08-01 20:32:45 +0100
committerIan Cottrell <iancottrell@google.com>2015-08-01 20:32:45 +0100
commitaa200265591ab5822a1716dccef23a3ddd7714c5 (patch)
treecc483916fc2f861057bac8c7bb3552b59d732110 /tools
parentc469e70ec218bd00769bc7961e58db39bd025e76 (diff)
downloadgpu-aa200265591ab5822a1716dccef23a3ddd7714c5.tar.gz
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
Diffstat (limited to 'tools')
-rw-r--r--tools/codergen/format/writer.go6
-rw-r--r--tools/codergen/template/embed.go1
-rw-r--r--tools/codergen/template/go_binary.tmpl1
3 files changed, 6 insertions, 2 deletions
diff --git a/tools/codergen/format/writer.go b/tools/codergen/format/writer.go
index fbe521591..0bd47e244 100644
--- a/tools/codergen/format/writer.go
+++ b/tools/codergen/format/writer.go
@@ -42,6 +42,7 @@ type Writer struct {
out *tabwriter.Writer
space bytes.Buffer
depth int
+ lastDepth int
newline bool
Indent string
disabled bool
@@ -93,6 +94,11 @@ func (w *Writer) Write(data []byte) (n int, err error) {
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 c9e2c9d4c..d0357c56c 100644
--- a/tools/codergen/template/embed.go
+++ b/tools/codergen/template/embed.go
@@ -243,7 +243,6 @@ const go_binary_tmpl = `{{/*
{{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 9cea41f38..5319e7b23 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}}},¶