Recurse doc problem

This commit is contained in:
Mike Farah 2023-06-05 14:46:59 -07:00
parent fd67748078
commit 28909bbc5a
3 changed files with 19 additions and 3 deletions

View File

@ -75,6 +75,11 @@ yq '[... | {"p": path | join("."), "isKey": is_key, "hc": headComment, "lc": lin
```
will output
```yaml
- p: ""
isKey: false
hc: ""
lc: ""
fc: ""
- p: ""
isKey: false
hc: ""
@ -135,6 +140,11 @@ yq '[... | {"p": path | join("."), "isKey": is_key, "hc": headComment, "lc": lin
```
will output
```yaml
- p: ""
isKey: false
hc: ""
lc: ""
fc: ""
- p: ""
isKey: false
hc: ""
@ -259,8 +269,6 @@ yq '... comments=""' sample.yml
```
will output
```yaml
# hi
a: cat
b:
```

View File

@ -31,6 +31,7 @@ yq '..' sample.yml
will output
```yaml
a: frog
a: frog
frog
```
@ -92,6 +93,7 @@ yq '...' sample.yml
will output
```yaml
a: frog
a: frog
a
frog
```
@ -109,6 +111,9 @@ yq '[..]' sample.yml
```
will output
```yaml
- a: &cat
c: frog
b: *cat
- a: &cat
c: frog
b: *cat

View File

@ -25,7 +25,10 @@ func recursiveDecent(results *list.List, context Context, preferences recursiveD
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
candidate = candidate.unwrapDocument()
if candidate.Kind == DocumentNode {
results.PushBack(candidate)
candidate = candidate.unwrapDocument()
}
log.Debugf("Recursive Decent, added %v", NodeToString(candidate))
results.PushBack(candidate)