findNestedSection locates the section of YAML that corresponds to the given JSON path
(yamlContent string, pathSegments []PathSegment)
| 375 | |
| 376 | // findNestedSection locates the section of YAML that corresponds to the given JSON path |
| 377 | func findNestedSection(yamlContent string, pathSegments []PathSegment) NestedSection { |
| 378 | lines := strings.Split(yamlContent, "\n") |
| 379 | |
| 380 | foundLine, baseIndentLevel := findNestedSectionStart(lines, pathSegments) |
| 381 | if foundLine == -1 { |
| 382 | return NestedSection{startLine: -1, endLine: -1, baseIndentLevel: 0} |
| 383 | } |
| 384 | endLine := findNestedSectionEnd(lines, foundLine, baseIndentLevel) |
| 385 | return NestedSection{startLine: foundLine, endLine: endLine, baseIndentLevel: baseIndentLevel} |
| 386 | } |
| 387 | |
| 388 | func findNestedSectionStart(lines []string, pathSegments []PathSegment) (int, int) { |
| 389 | currentLevel := 0 |
no test coverage detected