(yamlContent string, nestedSection NestedSection)
| 324 | } |
| 325 | |
| 326 | func extractNestedSubYAML(yamlContent string, nestedSection NestedSection) (string, int) { |
| 327 | lines := strings.Split(yamlContent, "\n") |
| 328 | subYAMLLines := make([]string, 0, nestedSection.endLine-nestedSection.startLine+1) |
| 329 | var baseIndent = -1 |
| 330 | for lineNum := nestedSection.startLine; lineNum <= nestedSection.endLine && lineNum < len(lines); lineNum++ { |
| 331 | line := lines[lineNum] |
| 332 | |
| 333 | if lineNum == nestedSection.startLine { |
| 334 | continue |
| 335 | } |
| 336 | |
| 337 | lineIndent := len(line) - len(strings.TrimLeft(line, " \t")) |
| 338 | if baseIndent == -1 && strings.TrimSpace(line) != "" { |
| 339 | baseIndent = lineIndent |
| 340 | } |
| 341 | |
| 342 | var normalizedLine string |
| 343 | if lineIndent >= baseIndent && baseIndent > 0 { |
| 344 | normalizedLine = line[baseIndent:] |
| 345 | } else { |
| 346 | normalizedLine = line |
| 347 | } |
| 348 | |
| 349 | subYAMLLines = append(subYAMLLines, normalizedLine) |
| 350 | } |
| 351 | return strings.Join(subYAMLLines, "\n"), baseIndent |
| 352 | } |
| 353 | |
| 354 | func mapNestedLocationToOriginal(subLocation JSONPathLocation, nestedSection NestedSection, baseIndent int) JSONPathLocation { |
| 355 | originalLine := nestedSection.startLine + subLocation.Line // +1 to skip section header, -1 for 0-based indexing |
no outgoing calls
no test coverage detected