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

View File

@ -31,6 +31,7 @@ yq '..' sample.yml
will output will output
```yaml ```yaml
a: frog a: frog
a: frog
frog frog
``` ```
@ -92,6 +93,7 @@ yq '...' sample.yml
will output will output
```yaml ```yaml
a: frog a: frog
a: frog
a a
frog frog
``` ```
@ -109,6 +111,9 @@ yq '[..]' sample.yml
``` ```
will output will output
```yaml ```yaml
- a: &cat
c: frog
b: *cat
- a: &cat - a: &cat
c: frog c: frog
b: *cat 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() { for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode) 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)) log.Debugf("Recursive Decent, added %v", NodeToString(candidate))
results.PushBack(candidate) results.PushBack(candidate)