Skip to content

Commit dc4a382

Browse files
committed
Fix indention problem with lists in lists
In `dyff`, an issue was reported that showed the wrong usage of the indention prefix in lists in lists: ``` cluster-1 - one list entry removed: + two list entries added: - │ - x1 - │ - x1 │ - x5 │ - x5 │ - x10 - x999 ``` The correct style would be like this: ``` cluster-1 - one list entry removed: + two list entries added: - - x1 - - x1 │ - x5 │ - x5 │ - x10 - x999 ``` Add two additional checks in the sequence node code to correctly use the indention prefix only in list entries other than the first one. An exception of that rule is in case `skipIndentOnFirstLine` is `false`.
1 parent 3c43889 commit dc4a382

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+
2525
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
2626
github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
2727
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
28-
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
29-
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
3028
github.com/pkg/errors v0.9.0 h1:J8lpUdobwIeCI7OiSxHqEwJUKvJwicL5+3v1oe2Yb4k=
3129
github.com/pkg/errors v0.9.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
3230
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

output_yaml.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,17 @@ func (p *OutputProcessor) neatYAMLofNode(prefix string, skipIndentOnFirstLine bo
192192
}
193193

194194
case yamlv3.SequenceNode:
195-
for _, entry := range node.Content {
196-
fmt.Fprint(p.out, prefix, p.colorize("-", "dashColor"), " ")
195+
for i, entry := range node.Content {
196+
if i == 0 {
197+
if !skipIndentOnFirstLine {
198+
fmt.Fprint(p.out, prefix)
199+
}
200+
} else {
201+
fmt.Fprint(p.out, prefix)
202+
}
203+
204+
fmt.Fprint(p.out, p.colorize("-", "dashColor"), " ")
205+
197206
if err := p.neatYAMLofNode(prefix+p.prefixAdd(), true, entry); err != nil {
198207
return err
199208
}

0 commit comments

Comments
 (0)