fix tree indentation

This commit is contained in:
Josh Deprez 2021-09-03 09:13:12 +10:00
parent 5bf3b88881
commit 9717ab565f
2 changed files with 6 additions and 6 deletions

View file

@ -16,7 +16,7 @@ var (
) )
func init() { func init() {
gob.Register(ImageRef{}) gob.Register(&ImageRef{})
} }
// ImageRef loads images from the AssetFS into *ebiten.Image form. It is your // ImageRef loads images from the AssetFS into *ebiten.Image form. It is your

View file

@ -86,20 +86,20 @@ func (g *Game) cmdTree(dst io.Writer, argv []string) {
return return
} }
} }
PreorderWalk(c, func(c, p interface{}) error { PreorderWalk(c, func(w, _ interface{}) error {
indent := "" indent := ""
l := 0 l := 0
for ; p != nil; p = g.par[p] { for p := w; p != c; p = g.par[p] {
l++ l++
} }
if l > 0 { if l > 0 {
indent = strings.Repeat(" ", l-1) + "↳ " indent = strings.Repeat(" ", l-1) + "↳ "
} }
i, ok := c.(Identifier) i, ok := w.(Identifier)
if ok { if ok {
fmt.Fprintf(dst, "%s%T %q\n", indent, c, i.Ident()) fmt.Fprintf(dst, "%s%T %q\n", indent, w, i.Ident())
} else { } else {
fmt.Fprintf(dst, "%s%T\n", indent, c) fmt.Fprintf(dst, "%s%T\n", indent, w)
} }
return nil return nil
}) })