MCPcopy Create free account
hub / github.com/github/gh-aw / findNestedSectionEnd

Function findNestedSectionEnd

pkg/parser/json_path_locator.go:416–438  ·  view source on GitHub ↗
(lines []string, foundLine, baseIndentLevel int)

Source from the content-addressed store, hash-verified

414}
415
416func findNestedSectionEnd(lines []string, foundLine, baseIndentLevel int) int {
417 endLine := len(lines) - 1 // Default to end of file
418 targetLevel := baseIndentLevel - 1 // The level of the key we found
419
420 for lineNum := foundLine + 1; lineNum < len(lines); lineNum++ {
421 line := lines[lineNum]
422 trimmedLine := strings.TrimSpace(line)
423
424 if trimmedLine == "" || strings.HasPrefix(trimmedLine, "#") {
425 continue
426 }
427
428 lineLevel := (len(line) - len(strings.TrimLeft(line, " \t"))) / 2
429
430 // If we find a line at the same or lower level than our target,
431 // the nested section ends at the previous line
432 if lineLevel <= targetLevel {
433 endLine = lineNum - 1
434 break
435 }
436 }
437 return endLine
438}

Callers 1

findNestedSectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected