Commit 666afa1c authored by Robert Griesemer's avatar Robert Griesemer

2nd attempt: no noIndent for string lists

- slightly better output in general
- extra indentation where we could do without
  (however that seems better for now that not having the indentation
  where it is needed)
- no information is lost, so a future better approach can fix these
  places up again

R=rsc
http://go/go-review/1017050
parent f93ecca3
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
const ( const (
oneLineFuncDecls = false; oneLineFuncDecls = false;
compositeLitBlank = false; compositeLitBlank = false;
stringListMode = exprListMode(0); // previously: noIndent
) )
...@@ -113,7 +114,7 @@ func (p *printer) stringList(list []*ast.BasicLit, multiLine *bool) { ...@@ -113,7 +114,7 @@ func (p *printer) stringList(list []*ast.BasicLit, multiLine *bool) {
for i, x := range list { for i, x := range list {
xlist[i] = x; xlist[i] = x;
} }
p.exprList(noPos, xlist, noIndent, multiLine); p.exprList(noPos, xlist, stringListMode, multiLine);
} }
......
...@@ -144,6 +144,43 @@ func _() { ...@@ -144,6 +144,43 @@ func _() {
} }
const _ = F1 +
`string = "%s";`
`ptr = *;`
`datafmt.T2 = s ["-" p "-"];`
const _ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`
const _ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`
func _() {
_ = F1 +
`string = "%s";`
`ptr = *;`
`datafmt.T2 = s ["-" p "-"];`;
_ =
`datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`;
_ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`;
}
func _() { func _() {
// respect source lines in multi-line expressions // respect source lines in multi-line expressions
_ = a + _ = a +
......
...@@ -152,6 +152,44 @@ func _() { ...@@ -152,6 +152,44 @@ func _() {
} }
const _ = F1 +
`string = "%s";`
`ptr = *;`
`datafmt.T2 = s ["-" p "-"];`
const _ =
`datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`
const _ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`
func _() {
_ = F1 +
`string = "%s";`
`ptr = *;`
`datafmt.T2 = s ["-" p "-"];`;
_ =
`datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`;
_ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`
}
func _() { func _() {
// respect source lines in multi-line expressions // respect source lines in multi-line expressions
_ = a+ _ = a+
......
...@@ -144,6 +144,43 @@ func _() { ...@@ -144,6 +144,43 @@ func _() {
} }
const _ = F1 +
`string = "%s";`
`ptr = *;`
`datafmt.T2 = s ["-" p "-"];`
const _ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`
const _ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`
func _() {
_ = F1 +
`string = "%s";`
`ptr = *;`
`datafmt.T2 = s ["-" p "-"];`;
_ =
`datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`;
_ = `datafmt "datafmt";`
`default = "%v";`
`array = *;`
`datafmt.T3 = s {" " a a / ","};`;
}
func _() { func _() {
// respect source lines in multi-line expressions // respect source lines in multi-line expressions
_ = a + _ = a +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment