mirror of
https://github.com/wader/fq.git
synced 2024-11-10 10:11:39 +03:00
decode: Fix walk root depth issue causing dump to indent incorrectly
This commit is contained in:
parent
8d442b82ee
commit
d1e1cd98c2
@ -90,7 +90,8 @@ func (v *Value) Walk(opts WalkOpts) error {
|
||||
}
|
||||
|
||||
rootDepthDelta := 0
|
||||
if wv.IsRoot {
|
||||
// only count switching to a new root
|
||||
if wv.IsRoot && wv != rootV {
|
||||
rootV = wv
|
||||
rootDepthDelta = 1
|
||||
}
|
||||
|
@ -322,10 +322,6 @@ func dump(v *decode.Value, w io.Writer, opts Options) error {
|
||||
if opts.Depth != 0 && depth > opts.Depth {
|
||||
return decode.ErrWalkSkipChildren
|
||||
}
|
||||
// skip first root level
|
||||
if rootDepth > 0 {
|
||||
rootDepth--
|
||||
}
|
||||
|
||||
return fn(v, rootV, depth, rootDepth)
|
||||
}
|
||||
|
1
pkg/interp/testdata/display.fqtest
vendored
1
pkg/interp/testdata/display.fqtest
vendored
@ -427,3 +427,4 @@ $ fq -n '"broken" | mp3 | d'
|
||||
| | | headers: [0]
|
||||
| | | frames: [0]
|
||||
0x0|62 72 6f 6b 65 6e| |broken| | unknown0: raw bits
|
||||
# TODO: add root depth test
|
||||
|
Loading…
Reference in New Issue
Block a user